Forum > BGRABitmap and LazPaint

New version of BGRABitmap

(1/131) > >>


A new version of BGRABitmap (7.3) has been released.

UTF8 support
In this version, when a UTF8 filename is expected, it is reflected by the name of the function or of the parameter:

--- Code: ---    constructor TBGRAAnimatedGif.Create(filenameUTF8: string);
--- End code ---

When there was no UTF8-handling function, it has been added. The class TFileStreamUTF8 is now used whenever possible to ensure maximum support of any UTF8 character.

Gtk (linux)
There was a bug when drawing an image on the canvas, sometimes the image had offset. This is hopefully corrected in 7.3 (tested on Lubuntu 32-bit).

New units
- BGRAGrayscaleMask: it is a light version of a bitmap having only one grayscale and linear channel. It does not provide any drawing capacities for now, except setpixel and direct pixel access. It is used internally by BGRAText.

- BGRAReadBMP, BGRAReadGif, BGRAReadPCX, BGRAReadPng, BGRAReadPSD, BGRAReadTGA, BGRAReadIco, bgrareadjpeg, BGRAReadXPM: these units are readers for images, that are automatically included in the program, to provide optimisations, corrections and additions to the standard ones provided by FreePascal. You may not need to make explicit reference to them because you can use them using the new TBGRAImageFormat enumeration.

- BGRAReadLzp, BGRAWriteLzp, BGRALzpCommon: this introduce a new version of Lzp format that you can use just like other image formats. The Lzp use by default a kind of RLE that is fast and does a compression that is in general a bit less efficient than PNG but still quite good (and surely much fast than PNG or zstream). It also supports layers. The software LazPaint use this format to store layered images. Note that in BGRABitmap, for now, you can only load and save flat images, so loading a layered image will just give you the flattened image of it.

- BGRAThumbnail: this unit provide fast loading and computation of thumbnails (using to display images for browsing)

- UnzipperExt: provides an unzipper that works with streams and UTF8 filenames

To make it easy to display animated gif without using too much CPU, the following property has been added:

--- Code: ---    property TimeUntilNextImageMs: integer read GetTimeUntilNextImage;

--- End code ---
It returns the time in milliseconds before the next frame will be rendered. The value zero means that the Gif should be updated immedialty.

- TResampleFilter provides now rfBox, which is high quality version of the stretched image. Note that the algorithm for stretched draw has been changed, it is to some extent faster and gives nice results except when the size becomes smaller than a half. In this case, not all pixels may be used to compute the resulting image. This makes it fast whatever the size of the original image is.
- TBGRAImageFormat = (ifUnknown, ifJpeg, ifPng, ifGif, ifBmp, ifIco, ifPcx, ifPaintDotNet, ifLazPaint, ifOpenRaster, ifPsd, ifTarga, ifTiff, ifXwd, ifXPixMap) are all the formats read by BGRABitmap. This goes with the following functions:

--- Code: ---function DetectFileFormat(AFilenameUTF8: string): TBGRAImageFormat;
function DetectFileFormat(AStream: TStream; ASuggestedExtensionUTF8: string = ''): TBGRAImageFormat;
function SuggestImageFormat(AFilenameOrExtensionUTF8: string): TBGRAImageFormat;
function CreateBGRAImageReader(AFormat: TBGRAImageFormat): TFPCustomImageReader;
function CreateBGRAImageWriter(AFormat: TBGRAImageFormat; AHasTransparentPixels: boolean): TFPCustomImageWriter;
--- End code ---
- DefaultBGRAImageReader, DefaultBGRAImageWriter: if you want to specify a reader for a specific file format.
- VGAColors: provide the basic 16 colors separately from CSS colors
- The color conversion between HSLA, GSBA and RGBA have been optimised. Also more functions to decode a string describing a color:

--- Code: ---function BGRAToStr(c: TBGRAPixel; AColorList: TBGRAColorList = nil; AMaxDiff: Word= 0): string;
function StrToBGRA(str: string): TBGRAPixel; //full parse
function StrToBGRA(str: string; const DefaultColor: TBGRAPixel): TBGRAPixel; //full parse with default when error or missing values
function PartialStrToBGRA(str: string; const fallbackValues: TBGRAPixel; out error: boolean): TBGRAPixel; //partial parse allowed
procedure TryStrToBGRA(str: string; var parsedValue: TBGRAPixel; out missingValues: boolean; out error: boolean);
--- End code ---

Fixed a bug in FillShapeAliased about the computation of the horizontal position of the polygons.

Added the following function to apply a function on each vertex/face:

--- Code: ---     procedure ForEachVertex(ACallback: TVertex3DCallback);
    procedure ForEachFace(ACallback: TFace3DCallback);
--- End code ---
Added the possibility to set custom flags on vertex/faces with the property CustomFlag.

UTF8 support to load TBGRASliceScaling and TBGRAMultiSliceScaling objects

Fixed some compilation issues (constref instead of const).

Supports now both Lzp compression, i.e. Zstream and RLE.

UTF8 support more explicit. Use of TGrayscaleMask to reduce memory usage and speed it up.

There is no more LoadAsBmp32 as this is handled by BGRAReadBmp.

There are a lot of new functions for loading/saving:

--- Code: ---     procedure LoadFromFileUTF8(const filenameUTF8: string); virtual;
     procedure LoadFromFileUTF8(const filenameUTF8: string; AHandler: TFPCustomImageReader); virtual;
     procedure SaveToFileUTF8(const filenameUTF8: string); virtual; overload;
     procedure SaveToFileUTF8(const filenameUTF8: string; Handler:TFPCustomImageWriter); virtual; overload;
--- End code ---

To create a handler for a specific format, use CreateBGRAImageReader/CreateBGRAImageWriter.

The function Assign can now take instead of TBitmap any TRasterImage.

--- Code: ---    procedure Assign(ARaster: TRasterImage); override; overload;
--- End code ---

FillMask has an additional optional parameter DrawMode:

--- Code: ---    procedure FillMask(x,y: integer; AMask: TBGRACustomBitmap; color: TBGRAPixel; ADrawMode: TDrawMode); override;
    procedure FillMask(x,y: integer; AMask: TBGRACustomBitmap; texture: IBGRAScanner; ADrawMode: TDrawMode); override;
--- End code ---

There are new functions:

--- Code: ---    procedure CrossFade(ARect: TRect; Source1, Source2: IBGRAScanner; AFadePosition: byte; mode: TDrawMode = dmDrawWithTransparency); override;
    procedure CrossFade(ARect: TRect; Source1, Source2: IBGRAScanner; AFadeMask: IBGRAScanner; mode: TDrawMode = dmDrawWithTransparency); override;
    procedure StretchPutImage(ARect: TRect; Source: TBGRACustomBitmap; mode: TDrawMode; AOpacity: byte = 255); override;
--- End code ---

StretchPutImage does what is says: it is faster than storing the resampled image first with Resample and then use Putimage.
CrossFade: draws a transition between two images. If the fade position is a constant value, then it is equivalent to simple fade between two images. When using a fademask, you can vary the progression of the fade not only during time but also in space. For example you can make the left part of the image show Source1 and the right part show Source2.

You may need to adjust the values of the property ScanOffset if the images are not all aligned on the same top-left corner.

Some functions give you the resulting bounds of drawing an image with an affine transformation:

--- Code: ---     function GetImageAffineBounds(Origin,HAxis,VAxis: TPointF; Source: TBGRACustomBitmap): TRect;
     function GetImageAngleBounds(x,y: single; Source: TBGRACustomBitmap; angle: single; imageCenterX: single = 0; imageCenterY: single = 0; ARestoreOffsetAfterRotation: boolean = false): TRect;
--- End code ---
You should transmit these bounds to the drawing function you use after that.

VerticalFlip and HorizontalFlip now can take a rectangle as a parameter to specify the area to be flipped. Note that these functions do not care about the clipping rectangle, so if you want to take it into account, you need to do an IntersectRect with ClipRect.

Similary ApplyMask take more parameters:

--- Code: ---    procedure ApplyMask(mask: TBGRACustomBitmap; ARect: TRect; AMaskRectTopLeft: TPoint); override;
--- End code ---
To specify the area and an offset for the mask. ApplyMask do not care about the clipping rectangle either.

Drawing checkers is now a basic function:

--- Code: ---    procedure DrawCheckers(ARect: TRect; AColorEven,AColorOdd: TBGRAPixel);
--- End code ---

Thanks for the update!

Now i can load files with ñ (n tilde)

Wonderful  :)

StretchPutImage is cool you can add StretchAndDraw in a tcanvas as destination?

Also you can add noise filter? Is random bw or random rgb (select one with a radio button) with alpha in a slider. Also in photoshop if i remember well rhere is a blur parameter. Is usefull to add some realism or texture to images. Combined with a blend mode.

Now bgracontrols are faster thanks!

Also we have added uecontrols and analog controls. About 25 usable ui controls! Plus lazpaint!


[0] Message Index

[#] Next page

Go to full version