Einzelnen Beitrag anzeigen

mensch72

Registriert seit: 6. Feb 2008
838 Beiträge
 
#21

AW: Mobile: Wie können dem ImageViewer1 verschiedene .jpgs zugewiesen werden?

  Alt 2. Nov 2015, 16:50
google: "fmx load jpg"

-> http://stackoverflow.com/questions/2...ling-in-delphi
In FireMonkey, graphics are handled using specialized classes derived from FMX.Graphics.TCustomBitmapCodec that are registered with the FMX.Graphics.TBitmapCodecManager class. You use the general-purpose FMX.Graphics.TBitmap class for handling all graphics. When loading a graphic, it uses the appropriate registered codec (if it can find one), but when saving you have to specify the codec you want to use.

FireMonkey uses different codec implementations for each platform, thus there is no single class that you can subclass, like there is in VCL. So, in order to customize JPEG handling in FireMonkey, you will have to create your own TCustomBitmapCodec-derived codec and register it with TBitmapCodecManager (unregistering the existing classes for the .jpg and .jpeg file extensions). Here are the codec classes that FireMonkey currently implements:

Windows: TBitmapCodecWIC in FMX.Canvas.D2D.pas
OSX: TBitmapCodecQuartz in FMX.Canvas.Mac.pas
iOS: TBitmapCodecQuartz in FMX.Canvas.iOS.pas
Android: TBitmapCodecAndroid in FMX.Canvas.Android.pas
Using {$IFDEF} statements, you might be able to utilize those existing classes inside of your custom codec as needed.

-> http://codeverge.com/embarcadero.del...a-jpeg/1085948
But I looked into some FMX sources and searched for "JPEG" and found a code snippet that works. Here it is:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  Filter: TBitmapCodec;
  TempBitmap: TBitmap;
begin
  if OpenDialog1.Execute then begin
    TempBitmap := TBitmap.Create(0, 0);
    Filter := DefaultBitmapCodecClass.Create;
    Filter.LoadFromFile(OpenDialog1.FileName, 0, TempBitmap);
    ImageControl1.Bitmap.Assign(TempBitmap);
    Filter.Free;
    TempBitmap.Free;
  end;
end;
And the JPEG appears! - See more at: http://codeverge.com/embarcadero.del....3YuJ46k0.dpuf
  Mit Zitat antworten Zitat