X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=images%2Fio-libungif.c;h=7e6038945627a9ed47e3ed62d00c3b7814fb3577;hb=3bf8dcea45ce5f185788a798e576276831b6432d;hp=c46484311cbe980a86b6a5032a57972ee56d4e1a;hpb=4142115bf20293bef998d1f683ac7ce3008178fb;p=libucw.git diff --git a/images/io-libungif.c b/images/io-libungif.c index c4648431..7e603894 100644 --- a/images/io-libungif.c +++ b/images/io-libungif.c @@ -9,13 +9,13 @@ #undef LOCAL_DEBUG -#include "lib/lib.h" -#include "lib/mempool.h" -#include "lib/fastbuf.h" -#include "images/images.h" -#include "images/error.h" -#include "images/color.h" -#include "images/io-main.h" +#include +#include +#include +#include +#include +#include +#include #include @@ -147,7 +147,11 @@ libungif_read_data(struct image_io *io) /* Prepare image */ struct image_io_read_data_internals rdi; - if (unlikely(!image_io_read_data_prepare(&rdi, io, image->ImageDesc.Width, image->ImageDesc.Height, io->flags))) + uns read_flags = io->flags; + uns cs = read_flags & IMAGE_COLOR_SPACE; + if (cs != COLOR_SPACE_GRAYSCALE && cs != COLOR_SPACE_RGB) + read_flags = (read_flags & ~IMAGE_COLOR_SPACE & IMAGE_CHANNELS_FORMAT) | COLOR_SPACE_RGB; + if (unlikely(!image_io_read_data_prepare(&rdi, io, image->ImageDesc.Width, image->ImageDesc.Height, read_flags))) { DGifCloseFile(gif); return 0; @@ -180,10 +184,14 @@ libungif_read_data(struct image_io *io) if (pal_pos != pal_end) bzero(pal_pos, pal_end - pal_pos); if (rd->transparent_index >= 0 && (io->flags & IMAGE_IO_USE_BACKGROUND)) - color_put_grayscale(pal + rd->transparent_index, &io->background_color); + if (!color_put(io->context, &io->background_color, pal + rd->transparent_index, COLOR_SPACE_GRAYSCALE)) + { + DGifCloseFile(gif); + return 0; + } # define DO_ROW_END do{ \ - walk_row_start += dein_step; \ - if (walk_row_start >= img_end) \ + walk_row_start += dein_step; \ + while (walk_row_start >= img_end) \ { uns n = dein_next >> 1; walk_row_start = rdi.image->pixels + n, dein_step = dein_next; dein_next = n; } \ }while(0) # define IMAGE_WALK_PREFIX(x) walk_##x @@ -194,7 +202,7 @@ libungif_read_data(struct image_io *io) # define IMAGE_WALK_ROW_STEP 0 # define IMAGE_WALK_DO_STEP do{ *walk_pos = pal[*pixels++]; }while(0) # define IMAGE_WALK_DO_ROW_END DO_ROW_END -# include "images/image-walk.h" +# include break; } case 2: @@ -217,7 +225,7 @@ libungif_read_data(struct image_io *io) # define IMAGE_WALK_ROW_STEP 0 # define IMAGE_WALK_DO_STEP do{ *(u16 *)walk_pos = ((u16 *)pal)[*pixels++]; }while(0) # define IMAGE_WALK_DO_ROW_END DO_ROW_END -# include "images/image-walk.h" +# include break; } case 3: @@ -232,7 +240,11 @@ libungif_read_data(struct image_io *io) if (pal_pos != pal_end) bzero(pal_pos, pal_end - pal_pos); if (rd->transparent_index >= 0 && (io->flags & IMAGE_IO_USE_BACKGROUND)) - color_put_rgb(pal + 4 * rd->transparent_index, &io->background_color); + if (!color_put(io->context, &io->background_color, pal + 4 * rd->transparent_index, COLOR_SPACE_RGB)) + { + DGifCloseFile(gif); + return 0; + } # define IMAGE_WALK_PREFIX(x) walk_##x # define IMAGE_WALK_INLINE # define IMAGE_WALK_IMAGE (rdi.image) @@ -241,7 +253,7 @@ libungif_read_data(struct image_io *io) # define IMAGE_WALK_ROW_STEP 0 # define IMAGE_WALK_DO_STEP do{ byte *p = pal + 4 * (*pixels++); walk_pos[0] = p[0]; walk_pos[1] = p[1]; walk_pos[2] = p[2]; }while(0) # define IMAGE_WALK_DO_ROW_END DO_ROW_END -# include "images/image-walk.h" +# include break; } case 4: @@ -266,7 +278,7 @@ libungif_read_data(struct image_io *io) # define IMAGE_WALK_ROW_STEP 0 # define IMAGE_WALK_DO_STEP do{ *(u32 *)walk_pos = ((u32 *)pal)[*pixels++]; }while(0) # define IMAGE_WALK_DO_ROW_END DO_ROW_END -# include "images/image-walk.h" +# include break; } default: