Your code does not even use ImageEn at all. Why don't you use ImageEn?
Anyway... you need to set the position of the stream to 0 after LoadFromFile.
procedure TForm1.Button1Click(Sender: TObject);
// Load a png file into TMemoryStream and save the png file with a new name
var
iPNG: TIEPNGImage;
ims: TMemoryStream;
begin
iPNG := TIEPNGImage.Create;
try
ims := TMemoryStream.Create;
try
ims.LoadFromFile('111.png');
ims.Position := 0; // Add this
iPNG.LoadFromStream(ms);
iPNG.SaveToFile('222.png');
finally
ims.Free;
end;
finally
iPNG.Free;
end;
end;
You do not need to use PNGImage.
procedure TForm1.Button2Click(Sender: TObject);
// Load a png file into a TMemoryStream then save the png to a file with a new filename
var
ms: TMemoryStream;
begin
ms := TMemoryStream.Create;
try
ms.LoadFromFile('111.png');
ms.Position := 0;
ms.SaveToFile('222.png');
finally
ms.Free;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
// Load a png file into a TMemory stream, then use imageenio to load the stream and save the png file
var
iImageEnIO: TImageENIO;
ims: TMemoryStream;
begin
iImageEnIO := TImageENIO.Create(nil);
try
ims := TMemoryStream.Create;
try
ims.LoadFromFile('111.png');
ims.Position := 0;
iImageEnIO.LoadFromStreamPNG(ims);
iImageEnIO.SaveToFilePNG('222.png');
finally
ims.Free;
end;
finally
iImageEnIO.Free;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
// Load a png file into a TMemory stream, then load the stream into ImageEnView, and use ImageEnView.IO to save the png file with a new name
var
ims: TMemoryStream;
begin
ims := TMemoryStream.Create;
try
ims.LoadFromFile('111.png');
ims.Position := 0;
ImageEnView1.IO.LoadFromStreamPNG(ims);
ImageEnView1.Update;
ImageEnView1.IO.SaveToFilePNG('222.png');
finally
ims.Free;
end;
end;
William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html