diff --git a/src/raster/quantization.cpp b/src/raster/quantization.cpp index 131906701..d43c023f3 100644 --- a/src/raster/quantization.cpp +++ b/src/raster/quantization.cpp @@ -78,7 +78,8 @@ Palette* quantization::create_palette_from_rgb(const Sprite* sprite) Image* quantization::convert_imgtype(const Image* image, int imgtype, DitheringMethod ditheringMethod, const RgbMap* rgbmap, - const Palette* palette) + const Palette* palette, + bool has_background_layer) { ase_uint32* rgb_address; ase_uint16* gray_address; @@ -109,6 +110,7 @@ Image* quantization::convert_imgtype(const Image* image, int imgtype, rgb_address = (ase_uint32*)image->dat; switch (new_image->imgtype) { + // RGB -> Grayscale case IMAGE_GRAYSCALE: gray_address = (ase_uint16*)new_image->dat; @@ -124,6 +126,7 @@ Image* quantization::convert_imgtype(const Image* image, int imgtype, gray_address++; } break; + // RGB -> Indexed case IMAGE_INDEXED: idx_address = new_image->dat; @@ -147,6 +150,7 @@ Image* quantization::convert_imgtype(const Image* image, int imgtype, gray_address = (ase_uint16*)image->dat; switch (new_image->imgtype) { + // Grayscale -> RGB case IMAGE_RGB: rgb_address = (ase_uint32*)new_image->dat; @@ -158,6 +162,7 @@ Image* quantization::convert_imgtype(const Image* image, int imgtype, rgb_address++; } break; + // Grayscale -> Indexed case IMAGE_INDEXED: idx_address = new_image->dat; @@ -178,12 +183,14 @@ Image* quantization::convert_imgtype(const Image* image, int imgtype, idx_address = image->dat; switch (new_image->imgtype) { + // Indexed -> RGB case IMAGE_RGB: rgb_address = (ase_uint32*)new_image->dat; for (i=0; igetEntry(c)), @@ -193,12 +200,14 @@ Image* quantization::convert_imgtype(const Image* image, int imgtype, rgb_address++; } break; + // Indexed -> Grayscale case IMAGE_GRAYSCALE: gray_address = (ase_uint16*)new_image->dat; for (i=0; igetEntry(c)); @@ -212,6 +221,7 @@ Image* quantization::convert_imgtype(const Image* image, int imgtype, gray_address++; } break; + } break; } diff --git a/src/raster/quantization.h b/src/raster/quantization.h index 4e299de4b..34b9cd97e 100644 --- a/src/raster/quantization.h +++ b/src/raster/quantization.h @@ -37,7 +37,8 @@ namespace quantization { Image* convert_imgtype(const Image* image, int imgtype, DitheringMethod ditheringMethod, const RgbMap* rgbmap, - const Palette* palette); + const Palette* palette, + bool has_background_layer); } diff --git a/src/undoable.cpp b/src/undoable.cpp index bcfea03d7..faf408f76 100644 --- a/src/undoable.cpp +++ b/src/undoable.cpp @@ -212,7 +212,8 @@ void Undoable::setImgType(int new_imgtype, DitheringMethod dithering_method) new_image = quantization::convert_imgtype(old_image, new_imgtype, dithering_method, rgbmap, // TODO check this out - m_sprite->getCurrentPalette()); + m_sprite->getCurrentPalette(), + m_sprite->getBackgroundLayer() != NULL); if (!new_image) return; /* TODO error handling: not enough memory! we should undo all work done */ diff --git a/src/util/clipboard.cpp b/src/util/clipboard.cpp index 9e4e253d0..e262da7bf 100644 --- a/src/util/clipboard.cpp +++ b/src/util/clipboard.cpp @@ -244,7 +244,8 @@ void clipboard::paste(SpriteWriter& sprite) else { RgbMap* rgbmap = sprite->getRgbMap(); src_image = quantization::convert_imgtype(clipboard_image, sprite->getImgType(), DITHERING_NONE, - rgbmap, sprite->getPalette(sprite->getCurrentFrame())); + rgbmap, sprite->getPalette(sprite->getCurrentFrame()), + false); } // Do the interactive-transform loop (where the user can move the floating image)