30504

Is there a limit to DecodeBase64 from EncdDecd?

Is there a limit on how large of a Base64 string you can pass in?

I'm using the following and when my image gets created it's missing a portion of the bottom. I see that BufferLen is ~44000 and yet DecodeBase64 returns about an array of about 24000 items.

BufferLen := (Length(JVal) * 4) div 3; SetLength(PtrB, BufferLen); PtrB := DecodeBase64(AnsiString(JVal)); JStream := TStringStream.Create(PtrB); Jpeg := TJPEGImage.Create; Jpeg.LoadFromStream(JStream); Self.JPG := Jpeg;

Answer1:

There is no size limitation on the code in the Soap.EncdDecd unit, beyond that imposed by the use of the AnsiString data type.

This program which successfully encodes and then decodes a 100MB string demonstrates the point:

{$APPTYPE CONSOLE} uses Soap.EncdDecd; var i: Integer; plain, encoded: string; begin SetLength(plain, 100*1024*1024); for i := 1 to Length(plain) do plain[i] := Chr(32+Random(80)); encoded := EncodeString(plain); if plain=DecodeString(encoded) then Writeln('passed') else Writeln('failed'); Readln; end.

Your problem almost certainly lies in your code rather than the EncdDecd unit.

You code could be quite a bit simpler. For example:

JStream := TBytesStream.Create(DecodeBase64(JVal)); Jpeg := TJPEGImage.Create; Jpeg.LoadFromStream(JStream);

Recommend

  • How to send a DELETE request with Indy?
  • NPAPI plugin framework Error
  • C# Find specific slot no of the USB Hub(10 slots) where USB is connected or not. I want to get the s
  • LoadStringFromFile into compiled script (so available on system that doesn't have the file)? [d
  • Delphi XE and ZLib Problems (II)
  • Remove attributes from XElement
  • Builder pattern
  • unique_ptr as class member and move semantics fail to compile with clang
  • Why does the following protocol have this required function?
  • One form two action
  • static ints, compilation units and the ternary operator
  • jQuery - why can't I bind events to elements in a loop?
  • Sharepoint 2010 migration to sharepoint online using sharegate
  • Alternatives to Search and Replace to use for telling to an application where to put content in a Wo
  • TIdTCPServer not reading data from socket sometimes
  • PHP if or statement not working
  • Divide two String into substrings and pair them
  • Stringbuilder maximum length
  • Why do Rhino Stubs allow me to set expectations on them?
  • Django: nested content blocks with the same name
  • Find an integer not in list of 4 billion using 4 mb. But 4 MB is not enough [duplicate]
  • Powerquery: Expand all columns of that have records in them
  • Limitation on mobile cross platform development
  • Passing parameters from Delphi 5 to Delphi DLL XE
  • Implementing ignoredProperties() on both a Object subclass and its own subclass
  • Object Browser can't browse my own solution?
  • Default parameter using another parameter
  • custom string delimiters stringtemplate-4
  • Change multiple background-images with jQuery
  • FileReader+canvas image loading problem
  • Insert into database using onclick function
  • Android screen density dpi vs ppi
  • Deselecting radio buttons while keeping the View Model in synch
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • DirectX11 ClearRenderTargetViewback with transparent buffer?
  • Change an a tag attribute in JavaScript based on screen width
  • Comma separated Values
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]