ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 dynamic bmp to png conversion problem

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
kowal Posted - Jun 13 2022 : 14:55:52
I'm trying do save dynamically created bitmaps in png format with Transparency set on but with no good result.

Here is a snippet of my test code in which the problem may be probably seen.
I read the bitmap from the test file, and save it to be sure it is 32 bit with transparency set.
Then I read it into TIEBitmap object.

And here I get the PixelFormat of the IEBitmap object value ie24RGB not ie32RGB which I expect.

procedure TForm1.open_saveClick(Sender: TObject);
var bmp: TBitmap;
    iebmp: TIEBitmap;
    fn: string;
begin
  if odp.Execute() then
  begin
        fn := odp.FileName;

        bmp   := tBitmap.Create;
        bmp.TransparentMode := tmAuto;
        bmp.Transparent := true;
        bmp.LoadFromFile(fn);
        bmp.SaveToFile(fn);      // I save bmp with pf32bit

        iebmp := TIEBitmap.Create();
        iebmp.ParamsEnabled := True;
        iebmp.Params.BMP_HandleTransparency := True; // Alpha Channel will be saved (as a 32bit RGBA BMP)

        iebmp.Read(fn);       // iebmp.Pixelformat = ie24RGB

        iebmp.Write(StringReplace(fn,'.bmp','.png',[rfReplaceAll]));
        iebmp.Free;
        bmp.Free;
  end;
end;

May be the bitmap should be prepared in some different way, but don't know how to do it.


Kowalski



4   L A T E S T    R E P L I E S    (Newest First)
kowal Posted - Jun 15 2022 : 07:49:26
Hi Nigel
That works ok!
Thank you for your help!
xequte Posted - Jun 14 2022 : 15:04:52
Hi Kowalski

How about the following?

  // Convert a bitmap where the bottom-left pixel represents the transparent color to PNG
  bmp := TIEBitmap.Create;
  bmp.Read( 'D:\Glyph_Source.bmp');
  // Get transparent color (transColor is type TRGB)
  transColor := bmp.Pixels[ 0, bmp.Height - 1 ];
  bmp.SetTransparentColors( transColor, transColor, 0 );
  bmp.Write( 'D:\Glyph_Output.png');
  bmp.Free;






Nigel
Xequte Software
www.imageen.com
kowal Posted - Jun 14 2022 : 05:08:53
Hi,
this is the file I want to convert and the result of conversion
I intend to place png as a marker on the Google Maps.

The properties info from Windows is that it is 32 bit bmp image.

xequte Posted - Jun 13 2022 : 20:07:55
Hi Kowalski

If you are starting with a 24bit bitmap, there is no transparency, and even saving it as 32bit bitmap will only enable an alpha channel, but the image still won't contain any transparent pixels. Can you attach some example BMP files and show what you are a looking to do with them (e.g. how should transparent pixels be determined)?



Nigel
Xequte Software
www.imageen.com