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
 howto save alpha channel?

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
uko Posted - Oct 31 2013 : 06:06:02
Hi,

it seems to be a very stupid question, but: how can I save to alpha channel of a PNG file as an 8bit gray-scaled image? I tried it by following code but the resulting BMP is invalid:


  img := TIEBitmap.Create('tranparentMarker4.png');
  try
    if img.HasAlphaChannel then
    begin
      io := TImageEnIO.CreateFromBitmap(img.AlphaChannel);
      try
        io.SaveToFileBMP('alpha.bmp');
      finally
        io.Free;
      end;
    end;
  finally
    img.Free;
  end;


Then I cannot open that BMP by GIMP or IrfanView. I use Delphi XE with ImageEn 4.1.0. Attached is the initial PNG file.





best regards,
Ulrich
1   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Nov 02 2013 : 07:12:57
Are you just trying to save the png as a bitmap with alphachannel?

If so. this works:
procedure TForm1.Button1Click(Sender: TObject);
var
  iIEBitmap: TIEBitmap;
  iImageENIO: TImageEnIO;
begin
  iIEBitmap := TIEBitmap.Create('TranparentMarker4.png');
  try
    if iIEBitmap.HasAlphaChannel then
    begin
       iImageENIO := TImageEnIO.CreateFromBitmap(iIEBitmap);
      try
        iImageENIO.Params.BMP_HandleTransparency := True;
        iImageENIO.SaveToFileBMP('alpha.bmp');
      finally
        iImageENIO.Free;
      end;
    end;
  finally
    iIEBitmap.Free;
  end;
end;

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html