diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2002-07-01 22:30:51 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2002-07-01 22:30:51 +0000 |
commit | c43a93f9840669f41d6ed6d49e0e38e5b6bdcab5 (patch) | |
tree | a89fe11510126aa73805eb0a68fd71d704deb06f /gdk-pixbuf | |
parent | 155aa55bedfb06b0f065934edcf3ab93e8e42f1c (diff) | |
download | gtk+-c43a93f9840669f41d6ed6d49e0e38e5b6bdcab5.tar.gz |
Support for compressed ras images (#84994):
* io-ras.c (RAS2State): Error on unsupported ras variations.
(OneLine8): Fix colormap indexing.
(OneLine): Call updated_func with proper region.
(DoCompressed): New function, handles compressed ras data.
(gdk_pixbuf__ras_image_load_increment): Handle compressed ras
images.
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r-- | gdk-pixbuf/ChangeLog | 9 | ||||
-rw-r--r-- | gdk-pixbuf/io-ras.c | 67 |
2 files changed, 69 insertions, 7 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 078d646785..320060796a 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,5 +1,14 @@ 2002-07-02 Matthias Clasen <maclas@gmx.de> + Support for compressed ras images (#84994): + + * io-ras.c (RAS2State): Error on unsupported ras variations. + (OneLine8): Fix colormap indexing. + (OneLine): Call updated_func with proper region. + (DoCompressed): New function, handles compressed ras data. + (gdk_pixbuf__ras_image_load_increment): Handle compressed ras + images. + Better colorspace support for the jpeg loader (#61211): * io-jpeg.c (convert_cmyk_to_rgb): New function. diff --git a/gdk-pixbuf/io-ras.c b/gdk-pixbuf/io-ras.c index 593c89a86c..cc39e6a28e 100644 --- a/gdk-pixbuf/io-ras.c +++ b/gdk-pixbuf/io-ras.c @@ -85,7 +85,7 @@ struct ras_progressive_state { 8 = 8 bit colormapped 1 = 1 bit bitonal */ - + gint DecoderState; struct rasterfile Header; /* Decoded (BE->CPU) header */ @@ -181,6 +181,14 @@ static gboolean RAS2State(struct rasterfile *RAS, return FALSE; } + if (State->Header.type > 2 || State->Header.maptype > 1) { + g_set_error (error, + GDK_PIXBUF_ERROR, + GDK_PIXBUF_ERROR_CORRUPT_IMAGE, + _("unsupported RAS image variation")); + return FALSE; + } + /* Now pad the line to be a multiple of 16 bits */ if ((State->LineWidth & 1) != 0) State->LineWidth++; @@ -266,7 +274,8 @@ gdk_pixbuf__ras_image_begin_load(ModulePreparedNotifyFunc prepared_func, context->Lines = 0; context->RasType = 0; - + context->DecoderState = 0; + memset(&context->Header, 0, sizeof(struct rasterfile)); @@ -349,6 +358,7 @@ static void OneLine8(struct ras_progressive_state *context) { gint X; guchar *Pixels; + int offset = context->Header.maplength / 3; X = 0; Pixels = context->pixbuf->pixels + context->pixbuf->rowstride * context->Lines; @@ -357,9 +367,9 @@ static void OneLine8(struct ras_progressive_state *context) Pixels[X * 3 + 0] = context->HeaderBuf[context->LineBuf[X] + 32]; Pixels[X * 3 + 1] = - context->HeaderBuf[context->LineBuf[X] + 256 + 32]; + context->HeaderBuf[context->LineBuf[X] + offset + 32]; Pixels[X * 3 + 2] = - context->HeaderBuf[context->LineBuf[X] + 512 + 32]; + context->HeaderBuf[context->LineBuf[X] + 2*offset + 32]; X++; } } @@ -410,12 +420,50 @@ static void OneLine(struct ras_progressive_state *context) 0, context->Lines, context->Header.width, - context->Header.height, + 1, context->user_data); } } +static gboolean +DoCompressed (gpointer data, + const guchar * buf, guint size, + GError **error) +{ + int i; + struct ras_progressive_state *context = + (struct ras_progressive_state *) data; + + for (i = 0; i < size; i++) { + switch (context->DecoderState) { + case 0: + if (buf[i] == 0x80) + context->DecoderState = 1; + else + context->LineBuf[context->LineDone++] = buf[i]; + break; + case 1: + if (buf[i] == 0) { + context->LineBuf[context->LineDone++] = 0x80; + context->DecoderState = 0; + } + else + context->DecoderState = buf[i] + 1; + break; + default: + for (; context->DecoderState; context->DecoderState--) { + context->LineBuf[context->LineDone++] = buf[i]; + if ((context->LineDone >= context->LineWidth) && (context->LineWidth > 0)) + OneLine(context); + } + } + if ((context->LineDone >= context->LineWidth) && (context->LineWidth > 0)) + OneLine(context); + } + return TRUE; +} + /* * context - from image_begin_load * buf - new image data @@ -448,8 +496,13 @@ gdk_pixbuf__ras_image_load_increment(gpointer data, buf += BytesToCopy; context->HeaderDone += BytesToCopy; - } else { - /* Pixeldata only */ + } else if (context->Header.type == 2) { + if (!DoCompressed (context, buf, size, error)) { + return FALSE; + } + size = 0; + } + else { BytesToCopy = context->LineWidth - context->LineDone; if (BytesToCopy > size) |