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
 Unable to load PNG

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
GregoryW Posted - Dec 03 2012 : 04:24:57
Hi,
when i try to compile the code below [i am using Delphi XE, ImageEn 4.1.4]:
try
procedure TForm11.Button4Click(Sender: TObject);
var
  PNG: TIEPNGImage;
  ms: TMemoryStream;
begin
  PNG := TIEPNGImage.Create;
  ms := TMemoryStream.Create;
  try
    ms.LoadFromFile('111.png');
    PNG.LoadFromStream(ms);        <<< 1st error
    PNG.SaveToFile('222.png');     <<< 2nd error
  finally
    PNG.Free;
    ms.Free;
  end;
end;

I get errors like this:





PNG:


I need to load the images (*.png) from a stream. Am I doing something wrong? Please help!

No error messages when using old ImageEn (v3.1.2, for example), the code worked perfectly.

Greg
8   L A T E S T    R E P L I E S    (Newest First)
GregoryW Posted - Dec 11 2012 : 02:43:31
Thank you! Problem solved thanks to post made by 'fabrizio':

"This is my opinion about this problem: because both ImageEn and VCL uses zlib, but in different versions, maybe ImageEn links the VCL-zlib version. Structures of different zlib versions are also different, so they cannot work.
zlib is necessary to load/save PNG.
Putting zlib (and others like png, jpeg, etc..) object files in the same directory of ImageEn source code should fix the problen. Another way could be to put these object files (the libs content) in the first position of Delphi Library Path.

Fortunately this problem is fixed in XE2, because ImageEn can use the VCL-zlib library."
xequte Posted - Dec 11 2012 : 01:07:54
Hi Greg

We cannot reproduce this issue on our machines.

From the video it appears that Delphi's PNG library is being used instead of ImageEn's own one, so it is likely to be a path problem.

Please take a look at:

http://www.imageen.com/ieforum/topic.asp?TOPIC_ID=357


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
GregoryW Posted - Dec 11 2012 : 00:05:29
Dear xequte,

I sent an e-mail to support a few days ago titled "Unable to load PNG". Did you read it?

Greg
w2m Posted - Dec 05 2012 : 09:56:42
Discussing via email

William Miller
GregoryW Posted - Dec 04 2012 : 22:41:46
1) Delphi XE
2) ImageEn 4.1.4
3) only standard delphi units
4) nope
5) yes,
---------------------------
Error on creating PNG.
---------------------------
w2m Posted - Dec 04 2012 : 07:08:09
I did test my code... everything works as expected here.
1. What version of Delphi are you using?
2 What version of ImageEn are you using?
3. What components are in the project?
4. Perhaps you have more than one version of ImageEn installed.
5. Do you get an exception by running the exe outside of Delphi?

Send me your email address and I will send you a demo that we can test.

William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
GregoryW Posted - Dec 03 2012 : 22:02:31
Hi w2m,

please try to run your code:
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(ims);
      iPNG.SaveToFile('222.png');
    finally
      ims.Free;
    end;
  finally
   iPNG.Free;
  end;
end;

you get error message:
---------------------------
Error on creating PNG.
---------------------------

P.S. iPNG.SaveToFile('222.png') - this is just an example of a bug. In fact, I need a PNG (in TIEPNGImage) for further image manipulation.
w2m Posted - Dec 03 2012 : 07:22:58
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