Recent

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

circular

  • Hero Member
  • *****
  • Posts: 4122
    • 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: 4122
    • 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: 4122
    • 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: 4122
    • 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: 4122
    • 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: 294
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

Okoba

  • Hero Member
  • *****
  • Posts: 521
Re: New version of BGRABitmap
« Reply #683 on: December 06, 2023, 11:22:51 am »
Another good one. I like the BGRAPapers, thanks!

lainz

  • Hero Member
  • *****
  • Posts: 4400
    • https://lainz.github.io/
Re: New version of BGRABitmap
« Reply #684 on: December 06, 2023, 01:15:01 pm »
Hi, In OPM I've asked to be available the previous version:
https://github.com/bgrabitmap/bgrabitmap/releases/tag/v11.5.6

Because this bug:
https://github.com/bgrabitmap/bgrabitmap/issues/224

When a new version is released fixing that bug, we can ask again to be updated.

circular

  • Hero Member
  • *****
  • Posts: 4122
    • Personal webpage
Re: New version of BGRABitmap
« Reply #685 on: December 08, 2023, 12:01:56 pm »
Here is a quick release to fix significant issues with version 11.5.7.

Version 11.5.8:
- more paper sizes : DIN 476, Japanese, US, ANSI
- compilation fix for mseGUI (issue #225)
- runtime fix for LCL (issue #224)

https://github.com/bgrabitmap/bgrabitmap/releases

It introduces a class called TBGRAAnimatedPng that is in fact essentially the same as TBGRAAnimatedGif but has PNG format and 'apng' extension by default. This is needed to have distinct TGraphic class.

It is possible to show an animated PNG in a TImage, the only requirement is that the imported filename would be 'apng' so that it uses TBGRAAnimatedPng class instead of TPortableNetworkGraphic.

So TImage can be used now to display GIF and PNG animations.  :)
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4122
    • Personal webpage
Re: New version of BGRABitmap
« Reply #686 on: December 08, 2023, 12:05:38 pm »
Another good one. I like the BGRAPapers, thanks!
Hi Okoba,

It is great to see you around. I hope all is well in your projects.

And long life to beloved pixels!  :)
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 4400
    • https://lainz.github.io/
Re: New version of BGRABitmap
« Reply #687 on: December 12, 2023, 02:28:12 am »
GetMem sent me the confirmation email that the new version of bgrabitmap is in OPM now.  :)

circular

  • Hero Member
  • *****
  • Posts: 4122
    • Personal webpage
Re: New version of BGRABitmap
« Reply #688 on: December 13, 2023, 08:47:02 am »
Cool, thanks for notifying me. So all is well now :)
Conscience is the debugger of the mind

Okoba

  • Hero Member
  • *****
  • Posts: 521
Re: New version of BGRABitmap
« Reply #689 on: December 14, 2023, 05:44:50 pm »
Another good one. I like the BGRAPapers, thanks!
Hi Okoba,

It is great to see you around. I hope all is well in your projects.

And long life to beloved pixels!  :)

Thank you! Yes we both love them :) And lainz too :D
I always monitor your work, thank you for that. BTW, I emailed you before, so maybe you missed it.

 

TinyPortal © 2005-2018