-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Copied from Bitbucket.
jacobb repo owner created an issue 2017-03-25
It would be better to make GraphicEx image loading independent of TBitmap. That way we could also use it to directly load images into other formats. We could e.g. use it to directly load an image into a Graphics32 bitmap since our ColorManager is perfectly capable of converting to RGBA.
Rough proposal
IGraphicExLoader = interface
procedure SetWidth, SetHeight, SetColorFormat, ...
function GetDataRow // Scanline access
end;
TGraphicExGraphic = class
(...)
property BitmapInterface: IGraphicExLoader;
end;
TgexBitmap = class(TBitmap, IGraphicExLoader)
property Image: TGraphicExGraphic ...
end;
TgexBitmap32 = class(TBitmap32, IGraphicExLoader)
property Image: TGraphicExGraphic ...
end;
(TgexBufferedBitmap ... etc)
Loading an image
bmp := TgexBitmap.Create; // or TgexBitmap32.Create;
bmp.LoadFromFile(FileName); // Determines image type
or:
bmp.LoadFromFile(FileName, GraphicExImageClass);
or:
pict := TPicutre.Create;
pict.LoadFromFile(FileName); // Determines image type
LoadFromFile calls:
TGraphicExGraphicImage.Create(FileName);
then: LoadFromMemory.
LoadFromMemory processes image.
Then use interfaces to access parent image type (TBitmap, TBitmap32, ...)
to set PixelFormat, Width, Height and access ScanLine or other data storage.