Recent

Author Topic: New version of BGRABitmap  (Read 274913 times)

circular

  • Hero Member
  • *****
  • Posts: 4077
    • Personal webpage
Re: New version of BGRABitmap
« Reply #675 on: August 12, 2023, 10:42:02 pm »
MakeBitmapCopy does not handle really an alpha channel. It is intended to handle masked bitmap (either opaque or fully transparent pixels), as this is what's available in the LCL on all platforms. PixelFormat is buggy as far as I last tested it and is better not to use it.

With MakeBitmapCopy, you would still need to free the temporary TBitmap. In this case, the shared data is not linked to the TBGRABitmap so nothing bad happens.

Code: Pascal  [Select][+][-]
  1. var bmp: TBitmap;
  2. begin
  3.    ...
  4.    bmp := bgra.MakeBitmapCopy(clBtnFace);
  5.    AImage.Picture.Assign(bmp);
  6.    bmp.Free;
  7.    ...
  8. end;

Probably one of the simplest option if you want full transparency when available in the LCL is to store the image in a stream as PNG using TBGRABitmap.SaveToStreamAsPng and then load it into the TImage. Though that need some time to compress/decompress the PNG. It seems internally it uses Init_BPP32_B8G8R8A8_M1_BIO_TTB to define the RGBA format.
Code: Pascal  [Select][+][-]
  1. var stream: TMemoryStream;
  2. begin
  3.    ...
  4.    stream := TMemoryStream.Create;
  5.    bgra.SaveToStreamAsPng(stream);
  6.    stream.Position := 0;
  7.    AImage.Picture.PNG.LoadFromStream(stream);
  8.    stream.Free;
  9.    ...
  10. end;

What I would do is, instead of using a TImage for display, is to use a TBGRAVirtualScreen (opaque component) or TBGRAGraphicControl component of BGRAControls. This way, you can assign your image directly as BGRABitmap and always have alpha channel handling. If you need to prepare the image on form creation or that the area can be resized, then it is better to use the OnRedraw event and place/resize the image accordingly and put it on the Bitmap supplied as a parameter.

I have considered making a component that would be called TBCImage that would be like TImage but with a TBGRABitmap property.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4077
    • Personal webpage
Re: New version of BGRABitmap
« Reply #676 on: September 19, 2023, 08:13:21 am »
New version of BGRABitmap 11.5.6
https://github.com/bgrabitmap/bgrabitmap/releases/tag/v11.5.6

- AVIF format: support for libavif 1.0.0 (by DomingoGP)
- TIF format: support for BigTiff and YCbCr colorspace (by maxm74)
- Copy resolution when assigning image (by maxm74)
- Compilation fix for OpenBSD

Thanks to maxm74 and DomingoGP for the file formats update!
Conscience is the debugger of the mind

alex208210

  • Newbie
  • Posts: 4
Re: New version of BGRABitmap
« Reply #677 on: October 21, 2023, 03:14:18 pm »
Lazarus 2.2.6 FPC 3.2.2 BGRABitmap 11.5.6

not installed, requires fpgui_toolkit dependency

fpgui_toolkit is also not installed:
C:\lazarus\components\fpgui\src\corelib\gdi\fpg_oledragdrop.pas(113,23) Error: No matching implementation for interface method "SetData(const tagFORMATETC;var TagSTGMEDIUM;LongBool):LongInt; StdCall;" found

circular

  • Hero Member
  • *****
  • Posts: 4077
    • Personal webpage
Re: New version of BGRABitmap
« Reply #678 on: October 22, 2023, 04:15:24 pm »
Hello Alex,

I am not sure to understand what you're saying. Can you explain?

Regards

EDIT: I suppose you've chosen bgrabitmappack4fpgui.lpk instead of bgrabitmappack.lpk
« Last Edit: October 23, 2023, 04:01:52 pm by circular »
Conscience is the debugger of the mind

alex208210

  • Newbie
  • Posts: 4
Re: New version of BGRABitmap
« Reply #679 on: October 29, 2023, 08:52:28 pm »
Hello Alex,

I am not sure to understand what you're saying. Can you explain?

Regards

EDIT: I suppose you've chosen bgrabitmappack4fpgui.lpk instead of bgrabitmappack.lpk
Sorry, No Problem!)

circular

  • Hero Member
  • *****
  • Posts: 4077
    • Personal webpage
Re: New version of BGRABitmap
« Reply #680 on: October 30, 2023, 06:47:08 am »
Ok, no problem. I am glad it works for you now.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4077
    • Personal webpage
Re: New version of BGRABitmap
« Reply #681 on: November 27, 2023, 01:10:22 am »
New version of BGRABitmap v11.5.7
https://github.com/bgrabitmap/bgrabitmap/releases

- added BGRAPapers unit (by maxm74)
- BGRABitmap package for Android
- compilation fix for assembler
- memory fix for SVG
- support for animated AVIF (by DomingoGP)
- support for animated PNG in TBGAAnimatedGif class
- added ResourceFile function (helpful for cross-platform with MacOS)
- data generation for GPT assistant

The package for Android bgrabitmappack4android.lpk avoids dependencies to OpenGL.

The ResourceFile function provided in BGRABitmapTypes finds a resource file near the binary (or in the parent folder on MacOS to make it more debugger friendly).
« Last Edit: November 28, 2023, 04:41:03 pm by circular »
Conscience is the debugger of the mind

nouzi

  • Sr. Member
  • ****
  • Posts: 289
Re: New version of BGRABitmap
« Reply #682 on: November 27, 2023, 11:05:52 am »
New version of BGRABitmap v11.5.7
https://github.com/bgrabitmap/bgrabitmap/releases

- added BGRAPapers unit (by maxm74)
- BGRABitmap package for Android
- compilation fix for assembler
- memory fix for SVG
- support for animated AVIF (by DomingoGP)
- added ResourceFile function (helpful for cross-platform with MacOS)
- data generation for GPT assistant

The package for Android bgrabitmappack4android.lpk avoids dependencies to OpenGL.

The ResourceFile function provided in BGRABitmapTypes finds a resource file near the binary (or in the parent folder on MacOS to make it more debugger friendly).

very good
My English is  bad
Lazarus last version free pascal last version
Lazarus trunk  free pascal trunk 
System : Linux mint  64bit  Windows 7 64bit

 

TinyPortal © 2005-2018