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
 How to save animated gif image correctly
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

mhieta

Finland
78 Posts

Posted - Mar 27 2012 :  02:21:10  Show Profile  Reply
Hi,

I'm using ImageEn 4.1.0.

Currently I'm using ImageEnMView component to save gif image what has frames with transparent background. But after saving image with ImageEnMView and loading saved image back to ImageEnMView I can see black stripe in second frame but not in the first frame. I guess that those black stripes are background color. What params do I need to set so I don't get those black stripes?

- Marko

xequte

39066 Posts

Posted - Mar 27 2012 :  02:45:59  Show Profile  Reply
Hi Marko

Can you please attach a screen shot of what you are seeing.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

mhieta

Finland
78 Posts

Posted - Mar 27 2012 :  07:25:30  Show Profile  Reply
Hi,

This black strip:



- Marko
Go to Top of Page

fab

1310 Posts

Posted - Mar 27 2012 :  13:47:37  Show Profile  Reply
Please could post the original GIF and the code you used?
Go to Top of Page

mhieta

Finland
78 Posts

Posted - Mar 28 2012 :  07:57:17  Show Profile  Reply
Hi,

Okay here is basically what I do now:

First I add page:

procedure TMDIChild.AddPageClick(Sender: TObject);
var
tempbmp: TBitmap;
idx: integer;
begin
idx := ImageEnMView1.SelectedImage;
if idx < 0 then
idx := 0;
ImageEnMView1.InsertImage(idx);
tempbmp := TBitmap.create;
tempbmp.width := 800;
tempbmp.height := 600;
tempbmp.pixelformat := pf24bit;
ImageEnMView1.SetImage(idx, tempbmp);
tempbmp.free;
for idx := 0 to ImageEnMView1.ImageCount - 1 do
begin
ImageEnMView1.ImageTopText[idx].Caption := 'Image ' + inttostr(idx);
ImageEnMView1.ImageInfoText[idx].Caption := inttostr(ImageEnMView1.ImageWidth[idx]) + ' x ' + inttostr(ImageEnMView1.ImageHeight[idx]);
end;
ImageEnMView1ImageSelect(nil, ImageEnMView1.SelectedImage);
Changed := true;
end;

Then I paste image in to ImageEnView and I update ImageEnMView page:

procedure TMDIChild.UpdatePageClick(Sender: TObject);
var
idx: integer;
begin
idx := ImageEnMView1.SelectedImage;
if idx>-1 then
begin
ImageEnView1.Proc.SaveUndo(ieuImage);
ImageEnMView1.SetIEBitmap(idx, ImageEnView1.IEBitmap);
ImageEnView1.Proc.Undo;
Changed := true;
end;
for idx := 0 to ImageEnMView1.ImageCount - 1 do
begin
ImageEnMView1.ImageTopText[idx].Caption := 'Image ' + inttostr(idx);
ImageEnMView1.ImageInfoText[idx].Caption := inttostr(ImageEnMView1.ImageWidth[idx]) + ' x ' + inttostr(ImageEnMView1.ImageHeight[idx]);
end;
end;

Then I can select page like this:

procedure TMDIChild.ImageEnMView1ImageSelect(Sender: TObject; idx: Integer);
var
Posit: Integer;
FileName3: String;
begin
ImageEnView1.IEBitmap.Assign(ImageEnMView1.GetTIEBitmap(idx));
ImageEnView1.Refresh;
end;

Then I save ImageEnMView gif file:

if (Ext = '.gif') then
begin
SaveImageEnDialog1.FilterIndex:=2;
end;
if SaveImageEnDialog1.Execute then
begin
(ActiveMDIChild as TMDIChild).Caption := SaveImageEnDialog1.FileName;
(ActiveMDIChild as TMDIChild).ImageEnMView1.MIO.SaveToFile((ActiveMDIChild as TMDIChild).Caption);
end;

Then I open gif image in to ImageEnMView:

if IEGetFileFramesCount(Name) > 1 then
begin
Child.ImageEnMView1.Clear;
Child.ImageEnMView1.LockPaint;
Child.ImageEnMView1.MIO.LoadFromFileAuto(Name);
for idx := 0 to Child.ImageEnMView1.ImageCount - 1 do
begin
Child.ImageEnMView1.ImageTopText[idx].Caption := 'Image ' + inttostr(idx);
Child.ImageEnMView1.ImageInfoText[idx].Caption := inttostr(Child.ImageEnMView1.ImageWidth[idx]) + ' x ' + inttostr(Child.ImageEnMView1.ImageHeight[idx]);
end;
Child.ImageEnMView1.UnLockPaint;
end;



- Marko
Go to Top of Page

mhieta

Finland
78 Posts

Posted - Mar 28 2012 :  07:59:34  Show Profile  Reply
Also please note that I stripped few lines of unneeded code. :)

- Marko
Go to Top of Page

fab

1310 Posts

Posted - Mar 28 2012 :  12:44:31  Show Profile  Reply
Is the file you have post the Original image or is it the resulting file after MIO.SaveToFile?
Go to Top of Page

mhieta

Finland
78 Posts

Posted - Mar 28 2012 :  13:07:45  Show Profile  Reply
That test_2.gif is result file after MIO.SaveToFile. test_2.gif is build from "scratch" by steps what I described in earlier message.

- Marko
Go to Top of Page

fab

1310 Posts

Posted - Mar 28 2012 :  13:31:54  Show Profile  Reply
Please send the original file, not the one you have saved with SaveToFile.
Go to Top of Page

mhieta

Finland
78 Posts

Posted - Mar 28 2012 :  22:02:44  Show Profile  Reply
Hi,

Here is the original image from the Firefox about:home page:



But I used screen shot from that about:home page and converted white color to transparent with Proc.SetTransparentColors. Thats why you see white area in my "This black strip:" post.

Anyway. I don't see black stripe before .MIO.SaveToFile.

- Marko
Go to Top of Page

mhieta

Finland
78 Posts

Posted - Mar 28 2012 :  23:11:12  Show Profile  Reply
Hi,

I think I found answer to that black stripe.
If those frames are different sizes then SaveToFile adjusts frame sizes (second frame not first one).
So I see then that black stripe. :) Now I need to make sure that frames are same sizes when saving animated gif.

- Marko
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: