Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
chris_hh  
#1 Posted : Monday, February 06, 2006 9:39:59 PM(UTC)
chris_hh

Rank: Member

Groups: Member
Joined: 2/6/2006(UTC)
Posts: 1

Hi, I got the following problem. I need to resize animated gifs. I use the img.Transforms.Resize(); method to resize every frame by the given ratio and set the new top, left for each frame. This works for many animated gifs, but there are also animated gifs that use somehow an overlay. The first image is an normal gif image, but the other frames of the animated gif just have the "changes" to the first gif and the rest seems to be transparent. I attached an example, if you look at it by each frame you will see what I mean. The Problem is when I try to resize this image, it just turns out really bad. Any help how I can resize these animated gifs is appreciated... Thanks, chris
chris_hh attached the following image(s):
test 1.gif
Dmitry  
#2 Posted : Wednesday, February 08, 2006 7:14:46 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hi Christian, As far as I understand your problem occurs because of precision loss caused by rounding. I afraid there is no simple workaround for it. I would try to solve this problem in the following way: 1. Render all frames as it should be displayed on the screen. To do it, you need to blend frames taking in account the disposal method; 2. Resize rendered frames; 3. Optimize frames. To do it, you need to calculate difference between frames as crop equal pixels; 4. Add optimized frames to GIF. The process of optimization of frames (step 3) is not difficult. Let's imagine that you have output from the step 2 as 24bpp Rgb images. Optimization process can be broken into some steps: 1. Create palette which you want to use in your GIF file for frames; 2. Convert all resized frames into indexed pixel format with the specified palette; 3. Add the first frame into the GIF; 4. Iteratively compare current frame with the previous one and create the result of comparison; 4.1 During comparing of frames: if a pixel of current frame equals to pixel of the previous frame - mark this pixel as transparent in result bitmap, if not - save pixel of current frame into result bitmap; 4.2 Find bounding rectangle of region which contains all non-transparent pixels in result bitmap; 4.3 Crop result bitmap by this region; 4.4 Set correct left-top corner of frame (according to crop region); 4.5 Set correct disposal method; 4.6 Add result bitmap into GIF as current frame. Please let me know if you have any questions regarding this matter.
Sincerely yours, Dmitry Sevostyanov UserPostedImage Follow Aurigma on Twitter!
Users browsing this topic
Forum Jump  
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.