Recent

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

circular

  • Hero Member
  • *****
  • Posts: 4224
    • Personal webpage
Re: New version of BGRABitmap
« Reply #660 on: May 28, 2023, 05:18:09 pm »
Exactly. BGRABitmap was and is one of the best libraries I worked with.
I am very much touched by your kind words. <3
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 4224
    • Personal webpage
Re: New version of BGRABitmap
« Reply #661 on: August 09, 2023, 07:41:04 pm »
BGRABitmap v11.5.5

- pixel resolution support for BMP, TIFF, JPEG, PCX, PNG, PSD
- add YCbCr colorspace family based on sRGB
- compatibility with older/newer Lazarus
- BGRABitmap4NoLCL package completely independant from LCL

https://github.com/bgrabitmap/bgrabitmap/releases
Conscience is the debugger of the mind

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: New version of BGRABitmap
« Reply #662 on: August 09, 2023, 10:31:49 pm »
Thanks for the new version.

What are the main differences with BGRABitmap4nogui and BGRABitmap4nolcl? Who are the target applications for each one?

circular

  • Hero Member
  • *****
  • Posts: 4224
    • Personal webpage
Re: New version of BGRABitmap
« Reply #663 on: August 10, 2023, 01:19:14 am »
BGRABitmap4nogui is in fact related to the LCL, but without graphic user interface (no GUI). So one can use for example LazFreeType with it.

BGRABitmap4nolcl is completely independant from the LCL. There is no more font rendering (neither system rendering nor from TrueType files). Though with another program that has the LCL, you could prepare a TBGRAVectorizedFont, compute necessary glyphs, save it to a file with SaveGlyphsToFile. Then in the program without LCL, load the file with LoadGlyphsFromFile.

Note that MSEgui provides system rendering of fonts, so this incorporated into an MSEgui program, you have the usual font rendering:
https://github.com/bgrabitmap/bgrabitmap/issues/139#issuecomment-1672184739
« Last Edit: August 10, 2023, 01:21:36 am by circular »
Conscience is the debugger of the mind

qk

  • New Member
  • *
  • Posts: 33
Re: New version of BGRABitmap
« Reply #664 on: August 11, 2023, 08:28:58 pm »
Thanks for the new version!
When will it be available on OPM?

Regards

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2100
  • Fifty shades of code.
    • Delphi & FreePascal
Re: New version of BGRABitmap
« Reply #665 on: August 11, 2023, 09:39:08 pm »
When I try to display Images, I just getting a black screen, what am I missing or do wrong?
Code: Pascal  [Select][+][-]
  1. procedure AssignBase64ToImage(const ABase64String: AnsiString; const AImage: TImage);
  2. var
  3.   bytes: TBytes;
  4.   graphic: TBGRABitmap;
  5.   stream: TStream;
  6.   bmp: TBitmap;
  7. begin
  8.   AImage.Picture.Clear;
  9.   bytes := Base64ToBytes(ABase64String);
  10.   if IsBRGACompatible(bytes) then
  11.     begin
  12.       graphic := TBGRABitmap.Create;
  13.       try
  14.         stream := TBytesStream.Create(bytes);
  15.         try
  16.           graphic.LoadFromStream(stream);
  17.           bmp := TBitmap.Create;
  18.           try
  19.             bmp.Assign(graphic.Bitmap);
  20.             AImage.Picture.Assign(bmp);
  21.           finally
  22.             bmp.Free;
  23.           end;
  24.         finally
  25.           stream.Free;
  26.         end;
  27.       finally
  28.         graphic.Free;
  29.       end;
  30.     end;
  31. end;
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

phoenix27

  • Jr. Member
  • **
  • Posts: 90
Re: New version of BGRABitmap
« Reply #666 on: August 11, 2023, 10:50:55 pm »
Circular, can BGRABitmap be used in Delphi?

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: New version of BGRABitmap
« Reply #667 on: August 11, 2023, 11:56:37 pm »
Circular, can BGRABitmap be used in Delphi?
Yes both bgrabitmap and bgracontrols

You need to use bgrabitmap 4 Delphi repository

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: New version of BGRABitmap
« Reply #668 on: August 11, 2023, 11:58:00 pm »
When I try to display Images, I just getting a black screen, what am I missing or do wrong?
Code: Pascal  [Select][+][-]
  1. procedure AssignBase64ToImage(const ABase64String: AnsiString; const AImage: TImage);
  2. var
  3.   bytes: TBytes;
  4.   graphic: TBGRABitmap;
  5.   stream: TStream;
  6.   bmp: TBitmap;
  7. begin
  8.   AImage.Picture.Clear;
  9.   bytes := Base64ToBytes(ABase64String);
  10.   if IsBRGACompatible(bytes) then
  11.     begin
  12.       graphic := TBGRABitmap.Create;
  13.       try
  14.         stream := TBytesStream.Create(bytes);
  15.         try
  16.           graphic.LoadFromStream(stream);
  17.           bmp := TBitmap.Create;
  18.           try
  19.             bmp.Assign(graphic.Bitmap);
  20.             AImage.Picture.Assign(bmp);
  21.           finally
  22.             bmp.Free;
  23.           end;
  24.         finally
  25.           stream.Free;
  26.         end;
  27.       finally
  28.         graphic.Free;
  29.       end;
  30.     end;
  31. end;

Create a tbgrabitmap and load from stream. Then assign to picture bitmap the bgrabitmap.bitmap, no need to use a temporary tbitmap. Also notice that you're freeing the bgrabitmap, that causes the tbitmap to don't be available anymore...

Or search the forums this was discussed already
« Last Edit: August 12, 2023, 12:14:24 am by lainz »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2100
  • Fifty shades of code.
    • Delphi & FreePascal
Re: New version of BGRABitmap
« Reply #669 on: August 12, 2023, 12:17:04 am »
Create a tbgrabitmap and load from stream. Then assign to picture bitmap the bgrabitmap.bitmap, no need to use a temporary tbitmap. Also notice that you're freeing the bgrabitmap, that causes the tbitmap to don't be available anymore...

Or search the forums this was discussed already
Same result. I try search forum okay.

I've overread your "free and it's gone", yes that is my problem, without free it display but thats somehow not what I wanted to have, a memoryleak.
I need to rethink ...
« Last Edit: August 12, 2023, 12:22:38 am by KodeZwerg »
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: New version of BGRABitmap
« Reply #670 on: August 12, 2023, 03:22:44 am »
If I remember correctly there is a function called makeBitmapCopy that you can use to avoid this problem.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2100
  • Fifty shades of code.
    • Delphi & FreePascal
Re: New version of BGRABitmap
« Reply #671 on: August 12, 2023, 11:39:44 am »
If I remember correctly there is a function called makeBitmapCopy that you can use to avoid this problem.
Thank you lainz, later I try to investigate it deeper.
ATM I am fine by doing it like this:
Code: Pascal  [Select][+][-]
  1.           graphic.LoadFromStream(stream);
  2.           bmp := TBitmap.Create;
  3.           try
  4.             bmp.PixelFormat := pf32bit;
  5.             bmp.Transparent := True;
  6.             bmp.SetSize(graphic.Width, graphic.Height);
  7.             bmp.Canvas.Lock;
  8.             try
  9.               bmp.Canvas.Draw(0, 0, graphic.Bitmap);
  10.             finally
  11.               bmp.Canvas.Unlock;
  12.             end;
  13.             AImage.Picture.Assign(bmp);
Regards, KodeZwerg
BGRABitmap rocks!
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

paweld

  • Hero Member
  • *****
  • Posts: 1003
Re: New version of BGRABitmap
« Reply #672 on: August 12, 2023, 02:59:45 pm »
@circular: Thank you very much.
Best regards / Pozdrawiam
paweld

circular

  • Hero Member
  • *****
  • Posts: 4224
    • Personal webpage
Re: New version of BGRABitmap
« Reply #673 on: August 12, 2023, 06:08:37 pm »
You're welcome  :)

Hi KodeZwerg!

Indeed, what happens here is that the raster data of the bitmap is shared when assigning it.

In the end, it seems you've written something a bit similar to MakeBitmapCopy, except maybe with transparent background. It is probably not portable to other systems, but if that works for you that's all good.
Conscience is the debugger of the mind

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2100
  • Fifty shades of code.
    • Delphi & FreePascal
Re: New version of BGRABitmap
« Reply #674 on: August 12, 2023, 08:55:43 pm »
You're welcome  :)

Hi KodeZwerg!

Indeed, what happens here is that the raster data of the bitmap is shared when assigning it.

In the end, it seems you've written something a bit similar to MakeBitmapCopy, except maybe with transparent background. It is probably not portable to other systems, but if that works for you that's all good.
Yeah, I didnt knew it better to help myself.
Maby you having a solution for me by calling the MakeBitmapCopy() method correct?
Code: Pascal  [Select][+][-]
  1.             bmp.PixelFormat := graphic.Bitmap.PixelFormat;
  2.             bmp.Transparent := graphic.HasTransparentPixels;
This is how I currently do with my old way of doing but I having no idea about the arguments to put into MakeBitmapCopy() so it would work with whatever the transparency might be to work for all cases, like Icons or PNG's etc....
I am not that deep into graphics to find out on my own.
I've cloned current repo of your wonderful package but did not found any example usage for MakeBitmapCopy().
I guess in the end I just could "TImage.Picture.Bitmap := TBGRABitmap.MakeBitmapCopy(missing arguments...);"
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

 

TinyPortal © 2005-2018