I know another way, that has following limitations:
1) works only with alpha=0 or alpha=255. No semi-transparent pixels allowed.
2) it is very slow (for each pixel draws a rectangle on the canvas)
3) of course, when the metafile is scaled produces "big pixels"
Here is an example:
var
x, y:integer;
MetaFile:TMetaFile;
MetaCanvas:TCanvas;
bmp:TIEBitmap;
begin
// load image with alpha in ImageEnView1
ImageEnView1.IO.LoadFromFile('myimage.xxx');
bmp := ImageEnView1.IEBitmap;
MetaFile := TMetaFile.Create();
MetaFile.Enhanced := true;
MetaFile.Width := bmp.Width;
MetaFile.Height := bmp.Height;
MetaCanvas := TMetaFileCanvas.Create(MetaFile, 0);
for y:=0 to bmp.Height-1 do
begin
for x:=0 to bmp.Width-1 do
begin
if bmp.AlphaChannel.Pixels_ie8[x, y] > 0 then
begin
MetaCanvas.Brush.Color := TRGB2TColor(bmp.Pixels[x, y]);
MetaCanvas.FillRect(Rect(x, y, x+1, y+1));
end;
end;
end;
MetaCanvas.Free();
MetaFile.SaveToFile('testmeta.emf');
MetaFile.Free();
end;
TRGB2TColor is defined in "imageenproc" unit, while TIEBitmap in "hyieutils".