Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Friday, June 18, 2010 6:54:36 AM(UTC)
chakri_28

Groups: Registered
Posts: 7


Could some one please provide me a sample code to load a animated gif image and resize it and save it using Lead Tools Main API in version 12.0.

Thanks
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Friday, June 18, 2010 7:47:22 AM(UTC)
chakri_28

Groups: Registered
Posts: 7


Hi,
Could some one please provide me a sample code to load a animated gif image, resize it and save it using Lead Tools Main API in version 12.0.

I need to know what dlls are required and the classes used. A small code snippet is greatly appreciated.


Thanks
 
#3 Posted : Sunday, June 20, 2010 2:03:38 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

The following API code shows how to load an animated GIF image, resize it and save it:
+----------+
L_INT nRet;
L_INT nFlags = LOADFILE_ALLOCATE | LOADFILE_STORE;
FILEINFO FileInfo;                        /* LEAD File Information structure. */
LOADFILEOPTION LoadOpt;
SAVEFILEOPTION SaveOpt;
int i;
...
nRet = L_FileInfo(OpenFileName.lpstrFile, &FileInfo, FILEINFO_TOTALPAGES, NULL);
      
for(i = 0; i < FileInfo.TotalPages;i++)
{
LoadOpt.PageNumber = i;

nRet = L_LoadFile (OpenFileName.lpstrFile,
&BitmapHandle,
0,
ORDER_BGR,
nFlags,
NULL, NULL,&LoadOpt, NULL);

nRet = L_SizeBitmap (&BitmapHandle, 100, 100, SIZE_RESAMPLE);
         
SaveOpt.PageNumber = i;
SaveOpt.Flags = ESO_INSERTPAGE;
         
nRet = nRet = L_SaveFile("c:\\TEST2.gif",
&BitmapHandle,
FILE_GIF, 8, 0,
SAVEFILE_FIXEDPALETTE,
NULL,
NULL,
&SaveOpt);       
}
+----------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#4 Posted : Sunday, June 27, 2010 6:58:53 PM(UTC)
chakri_28

Groups: Registered
Posts: 7


Hello Maen,
Thanks for the sample. But I am looking for the Lead.Leadlib interface way of resizing animated gif.

please see attached the sample code and help me in getting this fixed to allow for animated gifs loading, resizing and saving in 12.0 version.

Thanks again.
File Attachment(s):
imagesample.txt (4kb) downloaded 38 time(s).
 
#5 Posted : Sunday, June 27, 2010 11:29:05 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)


The following code shows how you can load a GIF file, resize it and save it:
+--------------+
Dim i As Integer
LEAD1.GetFileInfo "c:\eye.gif", -1, FILEINFO_TOTALPAGES

For i = 0 To LEAD1.InfoTotalPages - 1

LEAD1.Load "c:\eye.gif", 0, i, 1
LEAD1.Size 100, 100, RESIZE_RESAMPLE
LEAD1.Save "c:\ResGif.gif", FILE_GIF, 8, 2, SAVE_APPEND

Next i
+--------------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#6 Posted : Monday, June 28, 2010 5:14:48 AM(UTC)
chakri_28

Groups: Registered
Posts: 7


Thanks Maen.

I will give it a try.

Chakri
 
#7 Posted : Monday, June 28, 2010 8:00:17 AM(UTC)
chakri_28

Groups: Registered
Posts: 7


Hi Maen,
I tried your code. It resizes and saves the new file but the image is not loading right. It is faded and does not repeat the animation. Please help with.

Thanks.
 
#8 Posted : Monday, June 28, 2010 8:11:31 AM(UTC)
chakri_28

Groups: Registered
Posts: 7


Please see attached the sample images. weather.gif after resizing to newgiffy2.gif

newgiffy2.gif is the new converted image using the code you gave. dont know whats making it blurry. please let me know.

Thanks.
File Attachment(s):
NEWGIFFY2.gif (493kb) downloaded 41 time(s).
 
#9 Posted : Tuesday, June 29, 2010 3:44:58 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Please send me the source GIF file that you are trying to resize.
You can either post it here or send it to support@leadtools.com and mention this forum post in your email.
When attaching to the forums, do NOT use the "Preview" feature. Also, put your attachments in a ZIP or RAR file.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#10 Posted : Tuesday, June 29, 2010 8:33:56 AM(UTC)
chakri_28

Groups: Registered
Posts: 7


Just sent the zip file to the support@leadtools.com

Thanks.
 
#11 Posted : Wednesday, June 30, 2010 2:06:42 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Chakri,
To properly resize an animated GIF file, you must scale all of the following using the same ratio:
1. Bitmap width and height for all frames. This is done using the Size method.
2. Global animation width and height.
3. BitmapLeft and Top for all frames.
You must then save the resulting image using one call to the Save method.

Here's a code sample that resizes the image to one half (50%) of its original size:
+----------------+
Dim i As Integer
AxLEAD1.UnlockSupport(LEADLib.SupportLockConstants.L_SUPPORT_GIFLZW, "sg8Z2XkjL")
AxLEAD1.Load("f:\Patches\ToAmin\Last\Today\90351_BKSL.gif", 0, 1, -1)

For i = 0 To AxLEAD1.BitmapListCount - 1
AxLEAD1.BitmapListIndex = i
AxLEAD1.Size(AxLEAD1.BitmapWidth / 2, AxLEAD1.BitmapHeight / 2, LEADLib.ResizeConstants.RESIZE_NORMAL)
AxLEAD1.BitmapLeft = AxLEAD1.BitmapLeft / 2
AxLEAD1.BitmapTop = AxLEAD1.BitmapTop / 2
Next i

AxLEAD1.AnimationHeight = AxLEAD1.AnimationHeight / 2
AxLEAD1.AnimationWidth = AxLEAD1.AnimationWidth / 2
AxLEAD1.Save("f:\Patches\ToAmin\Last\Today\90351_BKSLResized.gif", LEADLib.FileConstants.FILE_GIF, 8, 2, 0)
+----------------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.140 seconds.