Enviroment: Delphi XE5, Win7
I have VCL application. Want to use Firemonkey classes to little image processing. Task is to get thumbnails from image files.
bmp: TBitmap;
...
bmp := FMX.Graphics.TBitmap.Create(100, 100);
bmp.LoadThumbnailFromFile(filename, 100, 100);
Any combination of TBitmap and LoadFromFile, LoadFromStream, CreateFromFile fails with exception.
I tryed to load bmp, png, tif, jpg... always the same result.
In debugger I see the access violation exception in FMX.Canvas.D2D.pas in row:
TCanvasD2D.ImagingFactory.CreateDecoderFromStream(stream, GUID_NULL, WICDecodeMetadataCacheOnDemand, dec);
What should I do to avoid exception and get working code? To enable some codecs?
UPDATE: At all... can I use Firemonkey classes in VCL Application? It looks for me I can not. Am I right?
UPDATE2: Now I try to go with next approach Writing a FireMonkey DLL for use with a VCL application.
My Firemonkey DLL full code
library wnimage;
uses
System.SysUtils,
System.Classes,
FMX.Graphics;
{$R *.res}
function GetThumbnail(filename: String; width, height: Integer): TStream;
var
bmp, th: TBitmap;
begin
bmp := TBitmap.CreateFromFile(filename);
th := bmp.CreateThumbnail(width, height);
Result := TMemoryStream.Create;
th.SaveToStream(Result);
th.Free;
bmp.Free;
end;
exports
GetThumbnail;
begin
end.
And again I get the same Access violation exception at library row:
bmp := TBitmap.CreateFromFile(filename);