Skip to content

Make GraphicEx class independent of TBitmap #15

@Wormnest

Description

@Wormnest

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions