diff options
Diffstat (limited to 'src/image.cc')
-rw-r--r-- | src/image.cc | 100 |
1 files changed, 7 insertions, 93 deletions
diff --git a/src/image.cc b/src/image.cc index 462ec90c..3cb12eb0 100644 --- a/src/image.cc +++ b/src/image.cc @@ -31,13 +31,6 @@ using namespace dw::core; /* - * Local data - */ -static size_t linebuf_size = 0; -static uchar_t *linebuf = NULL; - - -/* * Create and initialize a new image structure. */ DilloImage *a_Image_new(int width, @@ -92,44 +85,13 @@ void a_Image_ref(DilloImage *Image) } /* - * Decode 'buf' (an image line) into RGB format. - */ -static uchar_t * - Image_line(DilloImage *Image, const uchar_t *buf, const uchar_t *cmap, int y) -{ - uint_t x; - - switch (Image->in_type) { - case DILLO_IMG_TYPE_INDEXED: - if (cmap) { - for (x = 0; x < Image->width; x++) - memcpy(linebuf + x * 3, cmap + buf[x] * 3, 3); - } else { - MSG("Gif:: WARNING, image lacks a color map\n"); - } - break; - case DILLO_IMG_TYPE_GRAY: - for (x = 0; x < Image->width; x++) - memset(linebuf + x * 3, buf[x], 3); - break; - case DILLO_IMG_TYPE_RGB: - /* avoid a memcpy here! --Jcid */ - return (uchar_t *)buf; - case DILLO_IMG_TYPE_NOTSET: - MSG_ERR("Image_line: type not set...\n"); - break; - } - return linebuf; -} - -/* * Set initial parameters of the image */ void a_Image_set_parms(DilloImage *Image, void *v_imgbuf, DilloUrl *url, int version, uint_t width, uint_t height, DilloImgType type) { - _MSG("a_Image_set_parms: width=%d height=%d\n", width, height); + MSG("a_Image_set_parms: width=%d height=%d\n", width, height); bool resize = (Image->width != width || Image->height != height); OI(Image)->setBuffer((Imgbuf*)v_imgbuf, resize); @@ -139,10 +101,6 @@ void a_Image_set_parms(DilloImage *Image, void *v_imgbuf, DilloUrl *url, Image->in_type = type; Image->width = width; Image->height = height; - if (3 * width > linebuf_size) { - linebuf_size = 3 * width; - linebuf = (uchar_t*) dRealloc(linebuf, linebuf_size); - } Image->State = IMG_SetParms; } @@ -151,6 +109,7 @@ void a_Image_set_parms(DilloImage *Image, void *v_imgbuf, DilloUrl *url, */ void a_Image_set_cmap(DilloImage *Image, const uchar_t *cmap) { + MSG("a_Image_set_cmap\n"); Image->cmap = cmap; Image->State = IMG_SetCmap; } @@ -160,6 +119,7 @@ void a_Image_set_cmap(DilloImage *Image, const uchar_t *cmap) */ void a_Image_new_scan(DilloImage *Image, void *v_imgbuf) { + MSG("a_Image_new_scan\n"); a_Bitvec_clear(Image->BitVec); Image->ScanNumber++; ((Imgbuf*)v_imgbuf)->newScan(); @@ -171,20 +131,13 @@ void a_Image_new_scan(DilloImage *Image, void *v_imgbuf) void a_Image_write(DilloImage *Image, void *v_imgbuf, const uchar_t *buf, uint_t y, int decode) { - const uchar_t *newbuf; - + MSG("a_Image_write\n"); dReturn_if_fail ( y < Image->height ); - if (decode) { - /* Decode 'buf' and copy it into the DicEntry buffer */ - newbuf = Image_line(Image, buf, Image->cmap, y); - ((Imgbuf*)v_imgbuf)->copyRow(y, (byte *)newbuf); - } - a_Bitvec_set_bit(Image->BitVec, y); - Image->State = IMG_Write; - /* Update the row in DwImage */ OI(Image)->drawRow(y); + a_Bitvec_set_bit(Image->BitVec, y); + Image->State = IMG_Write; } /* @@ -192,46 +145,7 @@ void a_Image_write(DilloImage *Image, void *v_imgbuf, */ void a_Image_close(DilloImage *Image) { + MSG("a_Image_close\n"); a_Image_unref(Image); } - -// Wrappers for Imgbuf ------------------------------------------------------- - -/* - * Increment reference count for an Imgbuf - */ -void a_Image_imgbuf_ref(void *v_imgbuf) -{ - ((Imgbuf*)v_imgbuf)->ref(); -} - -/* - * Decrement reference count for an Imgbuf - */ -void a_Image_imgbuf_unref(void *v_imgbuf) -{ - ((Imgbuf*)v_imgbuf)->unref(); -} - -/* - * Create a new Imgbuf - */ -void *a_Image_imgbuf_new(void *v_dw, int img_type, int width, int height) -{ - Layout *layout = ((Widget*)v_dw)->getLayout(); - if (!layout) { - MSG_ERR("a_Image_imgbuf_new: layout is NULL.\n"); - exit(1); - } - return (void*)layout->createImgbuf(Imgbuf::RGB, width, height); -} - -/* - * Last reference for this Imgbuf? - */ -int a_Image_imgbuf_last_reference(void *v_imgbuf) -{ - return ((Imgbuf*)v_imgbuf)->lastReference () ? 1 : 0; -} - |