Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 08-02-2019, 10:16 PM
FreakaZoid2 FreakaZoid2 is offline
Senior Member
Join Date: Jul 2009
Posts: 361
Default Convert C# base64 string back to an image.

I am trying to take a C# base64 string and convert it back to an image. But everything I try fails with invalid bitmap image. Does the C# have something different about its encoding or am I going about this wrong...
Third party software and there security is tight so I only have limited information available but I have the complete string 4262 bytes long.
here is the beginning sample of it.

0x4749463839614B016700F700000000000000330000660000 990000CC0000FF003300003333

C# Code:
activity.SignatureData = pOptions.PaymentProcessorResult.Root?.Element("signatureData") != null ? Convert.FromBase64String(pOptions.PaymentProcessorResult.Root?.Element("signatureData")?.Value ?? string.Empty) : null;
my Delphi code:
procedure TForm1.btn1Click(Sender: TObject);
  s : string;
  bytes : TBytes;
  Encoding : TEncoding;
  bytes := TNetEncoding.Base64.DecodeStringToBytes(mmo1.Lines.Text);
  s := TEncoding.ANSI.GetString(bytes);
  img1.Picture.Bitmap := BitmapFromBase64(s);

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

All times are GMT. The time now is 12:22 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.