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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 howto save alpha channel?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

uko

Germany
35 Posts

Posted - Oct 31 2013 :  06:06:02  Show Profile  Reply
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

w2m

USA
1990 Posts

Posted - Nov 02 2013 :  07:12:57  Show Profile  Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: