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?
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;
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.
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.