[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r9625: Use tRNS block, setting the i
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r9625: Use tRNS block, setting the image type to RGBA when it's used. |
Date: |
Tue, 19 Aug 2008 12:11:14 +0200 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9625
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2008-08-19 12:11:14 +0200
message:
Use tRNS block, setting the image type to RGBA when it's used.
modified:
libbase/GnashImagePng.cpp
------------------------------------------------------------
revno: 9624.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-19 10:52:01 +0200
message:
Handle transparency in palette images.
modified:
libbase/GnashImagePng.cpp
------------------------------------------------------------
revno: 9624.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Tue 2008-08-19 10:53:47 +0200
message:
Reduce / correct logging.
modified:
libbase/GnashImagePng.cpp
=== modified file 'libbase/GnashImagePng.cpp'
--- a/libbase/GnashImagePng.cpp 2008-08-18 23:53:04 +0000
+++ b/libbase/GnashImagePng.cpp 2008-08-19 08:53:47 +0000
@@ -156,30 +156,41 @@
// Convert indexed images to RGB
if (type == PNG_COLOR_TYPE_PALETTE)
{
- log_debug("Convertin palette PNG to RGB(A)");
+ log_debug("Converting palette PNG to RGB(A)");
png_set_palette_to_rgb(_pngPtr);
}
// Convert less-than-8-bit greyscale to 8 bit.
if (type == PNG_COLOR_TYPE_GRAY && bitDepth < 8)
{
- log_debug("Gray bit depth(%d) to 8", bitDepth);
+ log_debug("Setting grey bit depth(%d) to 8", bitDepth);
png_set_gray_1_2_4_to_8(_pngPtr);
}
+ // Apply the transparency block if it exists.
+ if (png_get_valid(_pngPtr, _infoPtr, PNG_INFO_tRNS))
+ {
+ log_debug("Applying transparency block, image is RGBA");
+ png_set_tRNS_to_alpha(_pngPtr);
+ _type = GNASH_IMAGE_RGBA;
+ }
+
// Make 16-bit data into 8-bit data
if (bitDepth == 16) png_set_strip_16(_pngPtr);
- // Set the type of the image.
- if (type & PNG_COLOR_MASK_ALPHA)
- {
- log_debug("Loading PNG image with alpha");
- _type = GNASH_IMAGE_RGBA;
- }
- else
- {
- log_debug("Loading PNG image without alpha");
- _type = GNASH_IMAGE_RGB;
+ // Set the type of the image if it hasn't been set already.
+ if (_type == GNASH_IMAGE_INVALID)
+ {
+ if (type & PNG_COLOR_MASK_ALPHA)
+ {
+ log_debug("Loading PNG image with alpha");
+ _type = GNASH_IMAGE_RGBA;
+ }
+ else
+ {
+ log_debug("Loading PNG image without alpha");
+ _type = GNASH_IMAGE_RGB;
+ }
}
// Convert 1-channel grey images to 3-channel RGB.
@@ -197,8 +208,8 @@
const size_t components = getComponents();
// We must have 3 or 4-channel data by this point.
- assert((_type == GNASH_IMAGE_RGB && components == 3) ||
- (_type == GNASH_IMAGE_RGBA && components == 4));
+ assert(_type == GNASH_IMAGE_RGB && components == 3 ||
+ _type == GNASH_IMAGE_RGBA && components == 4);
// Allocate space for the data
_pixelData.reset(new png_byte[width * height * components]);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r9625: Use tRNS block, setting the image type to RGBA when it's used.,
Benjamin Wolsey <=