migrate this code to work on android

procedure TForm1.CreateJpg(Data: string);
var
  JpegStream: TMemoryStream;
  JpegImage: TJPEGImage;
  Bitmap: TBitmap;
  tmpPos, tmpLen: integer;
  pp: string;
begin
  try


    tmpPos := Pos('B]>', Data);
    pp := Copy(Data, 5, tmpPos-5);
    tmpLen := StrToInt(pp);
    Data := Copy(Data, tmpPos+3, tmpLen);

    Bitmap := TBitmap.Create;
    try
      JpegImage := TJpegImage.Create;
      try
        JpegStream := TMemoryStream.Create;
        try
          TIdDecoderMIME.DecodeStream(Data, JpegStream);
          JpegStream.Position := 0;
          JpegImage.LoadFromStream(JpegStream);
        finally
          JpegStream.Free;
        end;
        with Bitmap do
        begin
          Canvas.Lock;
          try
            Width := JpegImage.Width;
            Height := JpegImage.Height;
            Canvas.StretchDraw(rect(0, 0, 200, 160), JpegImage);
          finally
            Canvas.Unlock;
          end;
        end;
      finally
        JpegImage.Free;
      end;
      img.Picture.Assign(Bitmap);
    finally
      Bitmap.Free;
    end;
  except
    on E: Exception do
      //
  end;
end;

Open in new window


i have this code that create JPG image using data string . i want to migrate this code to work on andriod i cant find where JPG declared in and andriod firemonkey
dolphin KingAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sinisa VukSoftware architectCommented:
No need to do any special in fmx. Try this simplified version...
rocedure CreateJpg(Data: String; img: TImage);
var
  JpegStream: TMemoryStream;
  Bitmap: TBitmap;
  tmpPos, tmpLen: integer;
  pp: String;
begin
  try
    tmpPos := POs('B]>', Data);
    pp := Copy(Data, 5, tmpPos-5);
    tmpLen := StrToInt(pp);
    Data := Copy(Data, tmpPos+3, tmpLen);

    Bitmap := TBitmap.Create;
    try
      try
        JpegStream := TMemoryStream.Create;
        try
          TIdDecoderMIME.DecodeStream(Data, JpegStream);
          JpegStream.Position := 0;
          Bitmap.LoadFromStream(JpegStream);
        finally
          JpegStream.Free;
        end;
      finally
      end;
      img.Assign(Bitmap);
    finally
      Bitmap.Free;
    end;
  except
    on E: Exception do
      //
  end;
end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.