Author |
Topic  |
|
bmesser
  
United Kingdom
234 Posts |
Posted - Sep 24 2013 : 04:06:36
|
Hi
I've had a good look but can't see anything new in the Demo area to do with the new functionality to create animated GIF's, maybe it's so easy to do that no one bothered, or maybe I overlooked it, but if there is anything can someone send me a link?
I did try in the help under TImageEnIO.InsertToFileGif and did spot three lines of code which although a start is not particularly that helpful.
Bruce.
|
|
bmesser
  
United Kingdom
234 Posts |
Posted - Sep 24 2013 : 05:36:58
|
Hi
I've now found the "Multi" demo's so I now have a better idea of how to proceed.
Bruce.
|
 |
|
bmesser
  
United Kingdom
234 Posts |
Posted - Sep 24 2013 : 06:33:06
|
Hi
I've looked at a couple of these demos and can save a valid animated GIF but wonder what I have to change to make the animation interval anything other than 1000 ms which it seems to be stuck at. I've tried this before saving without any luck.
for idx:=0 to ImageEnMView1.ImageCount-1 do
ImageEnMView1.ImageDelayTime[idx]:=30;
The other question is how do I control transparency when creating an animated GIF? I know that from the old TGifImage component that Anders Melander produced, he had written a small 'cartoon' demo where the first image was the 'solid' background and the other 'transparent' images were layered on top of it. See here http://melander.dk/articles/gifanimate/.
Can you do the same in ImageEN?
Bruce. |
 |
|
w2m
   
USA
1990 Posts |
Posted - Sep 24 2013 : 12:25:08
|
Bruce. I do not know how Melander does it with GIF because a GIF, does not have an alphachannel because GIF is a 256 color palette based format. But see the exception noted below.
The format supports up to 8 bits per pixel for each image, allowing a single image to reference its own palette of up to 256 different colors chosen from the 24-bit RGB color space. It also supports animations and allows a separate palette of up to 256 colors for each frame.
As a further refinement, each frame can designate one index as a "transparent background color": any pixel assigned this index takes on the color of the pixel in the same position from the background, which may have been determined by a previous frame of animation.
I think what this means is a GIF does not support an alphachnnel, so you are left only with either on (255) not transparent or (0) fully transparent by setting the GIF_FlagTranspColor and GIF_TranspColor IO.Param values. This means you can not have partial transparency (128).
TIOParamsVals.GIF_TranspColor Declaration property GIF_TranspColor: TRGB;
Description GIF_TranspColor is the transparency color (If GIF_FlagTranspColor is True). This color should exist in the image.
TIOParamsVals.GIF_FlagTranspColor Declaration property GIF_FlagTranspColor: boolean;
Description If True, the GIF_TranspColor color is valid (the image has a transparency color). Note: when the image contains an alpha channel (transparency channel) this property is handled automatically.
Example ImageEnView1.IO.Params.GIF_FlagTranspColor:=True; ImageEnView1.IO.Params.GIF_TranspColor:=CreateRGB(0,0,0); // black is the transparent color
I know this does not completely answer your question, but it may get you started. When you create each frame set the GIF_FlagTranspColor and GIF_TranspColor IO.Param values. Hopefully this will work. I have not tried to do this so I can not be of more help.
William Miller Adirondack Software & Graphics Email: w2m@frontiernet.net EBook: http://www.imageen.com/ebook/ Apprehend: http://www.frontiernet.net/~w2m/index.html |
 |
|
xequte
    
39078 Posts |
Posted - Sep 24 2013 : 12:33:06
|
Hi Bruce
As Bill mentioned, GIF does not have an alpha channel, only a color designated as transparent.
I expect what you say in Melander demo was a GIF that had been optimized his GIF to remove any repeated information (to make it smaller).
The same function in ImageEn is IEOptimizeGIF:
http://www.imageen.com/help/IEOptimizeGIF.html
Nigel Xequte Software www.xequte.com nigel@xequte.com |
 |
|
w2m
   
USA
1990 Posts |
Posted - Sep 24 2013 : 12:56:40
|
Bruce,
I just enhanced the Multi demo by adding a SetDelay button and a TEdit. The TEdit holds the delay in milliseconds. Then I called the code to set the delay in the SetDelay1OnClick event:
procedure TForm1.SetDelay1Click(Sender: TObject);
var
i: integer;
begin
for i := 0 to ImageEnMView1.ImageCount-1 do
ImageEnMView1.ImageDelayTime[i] := StrToInt(Delay1.Text);
end; I loaded an avi file and played it and watched how fast the frames changed. I then set the delay to 30 and played the same file again and it was much faster visually... so I think setting the imagedelaytime does indeed function as one would expect.
Hope this helps.
William Miller Adirondack Software & Graphics Email: w2m@frontiernet.net EBook: http://www.imageen.com/ebook/ Apprehend: http://www.frontiernet.net/~w2m/index.html |
 |
|
xequte
    
39078 Posts |
Posted - Sep 24 2013 : 13:59:41
|
Sorry, I didn't address that point. TImageEnMView.ImageDelayTime is used only for the "Playing" function of TImageEnMView, it is not saved.
Please try:
for idx := 0 to ImageEnMView1.ImageCount - 1 do
begin
ImageEnMView1.ImageDelayTime[idx] := 30; // Set interval for ImageEnMView display
ImageEnMView1.MIO.Params[idx].ImageDelayTime := 30; // Set interval to save in file
end;
More info:
http://www.imageen.com/help/TIOParamsVals.ImageDelayTime.html
Nigel Xequte Software www.xequte.com nigel@xequte.com |
 |
|
w2m
   
USA
1990 Posts |
Posted - Sep 24 2013 : 14:26:39
|
Nigel,
TIOParamsVals.ImageDelayTime is read only so this can not be set....
TIOParamsVals.ImageDelayTime
Declaration property ImageDelayTime : Integer (Read-only)
Description If the current file supports animation and has multiple frames, then this property provides access to the delay in MS (milliseconds) between images. E.g. if ImageDelayTime=2000 then each frame should be shown for 2 seconds when we are animating it. This is a read-only property which provides ready access to one of: - TIOParamsVals.AVI_FrameDelayTime - TIOParamsVals.GIF_DelayTime - TIOParamsVals.MEDIAFILE_FrameDelayTime - The frame interval tag of DICOM files
William Miller Adirondack Software & Graphics Email: w2m@frontiernet.net EBook: http://www.imageen.com/ebook/ Apprehend: http://www.frontiernet.net/~w2m/index.html |
 |
|
xequte
    
39078 Posts |
Posted - Sep 25 2013 : 03:15:08
|
Sorry, yes, of course it is.
Please use GIF_DelayTime instead.
for idx := 0 to ImageEnMView1.ImageCount - 1 do
begin
ImageEnMView1.ImageDelayTime[idx] := 30; // Set interval for ImageEnMView display
ImageEnMView1.MIO.Params[idx].DelayTime := 3; // Set interval to save in file - Note unit is 1/100th sec
end;
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
 |
|
|
Topic  |
|