[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11242: Read PNG and GIF data in Def
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11242: Read PNG and GIF data in DefineBits tags for all SWF versions (manually |
Date: |
Fri, 10 Jul 2009 08:05:22 +0200 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11242
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2009-07-10 08:05:22 +0200
message:
Read PNG and GIF data in DefineBits tags for all SWF versions (manually
tested), fixing bug #26994. Pre-process bitmap data with alpha for RGBA
images, fixing bad display of some images with transparency.
modified:
libbase/GnashImage.cpp
libbase/GnashImagePng.cpp
libcore/swf/tag_loaders.cpp
------------------------------------------------------------
revno: 11241.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2009-07-10 06:59:27 +0200
message:
Implement reading PNG and GIF data in DefineBits tags (fixes bug #26994).
modified:
libcore/swf/tag_loaders.cpp
------------------------------------------------------------
revno: 11241.1.2
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2009-07-10 07:35:21 +0200
message:
Use std::copy.
modified:
libbase/GnashImagePng.cpp
------------------------------------------------------------
revno: 11241.1.3
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2009-07-10 07:35:32 +0200
message:
Process alpha in all native RGBA images (only PNG and GIF) like we do for
JPEGS when alpha data is merged.
modified:
libbase/GnashImage.cpp
=== modified file 'libbase/GnashImage.cpp'
--- a/libbase/GnashImage.cpp 2009-02-25 22:33:03 +0000
+++ b/libbase/GnashImage.cpp 2009-07-10 05:35:32 +0000
@@ -39,11 +39,15 @@
namespace gnash
{
+namespace {
+ void processAlpha(boost::uint8_t* imageData, size_t pixels);
+}
+
//
// GnashImage
//
-/// Create an image taking ownership of the given buffer, supposedly of
height*pitch bytes
+/// Create an image taking ownership of the given buffer height*pitch bytes
GnashImage::GnashImage(boost::uint8_t* data, int width,
int height, int pitch, ImageType type)
:
@@ -292,10 +296,17 @@
return im;
}
- for (size_t i = 0; i < height; ++i)
- {
+ for (size_t i = 0; i < height; ++i) {
inChannel->readScanline(im->scanline(i));
}
+
+ // The renderers expect RGBA data to be preprocessed. JPEG images are
+ // never transparent, but the addition of alpha data stored elsewhere
+ // in the SWF is possible; in that case, the processing happens during
+ // mergeAlpha().
+ if (im->type() == GNASH_IMAGE_RGBA) {
+ processAlpha(im->data(), width * height);
+ }
return im;
}
@@ -340,5 +351,25 @@
return im;
}
+namespace {
+
+void
+processAlpha(boost::uint8_t* imageData, size_t pixels)
+{
+
+ boost::uint8_t* p = imageData;
+ for (size_t i = 0; i < pixels; ++i) {
+ boost::uint8_t alpha = *(p + 3);
+ *p = std::min(*p, alpha);
+ ++p;
+ *p = std::min(*p, alpha);
+ ++p;
+ *p = std::min(*p, alpha);
+ p += 2;
+ }
+}
+
+} // anonymous namespace
+
} // namespace gnash
=== modified file 'libbase/GnashImagePng.cpp'
--- a/libbase/GnashImagePng.cpp 2009-02-25 22:33:03 +0000
+++ b/libbase/GnashImagePng.cpp 2009-07-10 05:35:21 +0000
@@ -115,8 +115,9 @@
assert (_rowPtrs);
// Data packed as RGB / RGBA
- std::memcpy(imageData, _rowPtrs[_currentRow],
- getWidth() * getComponents());
+ const size_t size = getWidth() * getComponents();
+
+ std::copy(_rowPtrs[_currentRow], _rowPtrs[_currentRow] + size, imageData);
++_currentRow;
}
=== modified file 'libcore/swf/tag_loaders.cpp'
--- a/libcore/swf/tag_loaders.cpp 2009-06-15 14:53:11 +0000
+++ b/libcore/swf/tag_loaders.cpp 2009-07-10 04:59:27 +0000
@@ -349,13 +349,30 @@
return;
}
- // Read the image data.else
-
- boost::shared_ptr<IOChannel> ad( StreamAdapter::getFile(in,
+ char buf[3];
+ if (in.read(buf, 3) < 3) {
+ log_swferror(_("DEFINEBITS data too short to read type header"));
+ return;
+ }
+ in.seek(in.tell() - 3);
+
+ FileType ft = GNASH_FILETYPE_JPEG;
+
+ // Check the data type. The pp version 9,0,115,0 supports PNG and GIF
+ // in DefineBits tags, though it is not documented. The version makes
+ // no difference.
+ if (std::equal(buf, buf + 3, "\x89PN")) {
+ ft = GNASH_FILETYPE_PNG;
+ }
+ else if (std::equal(buf, buf + 3, "GIF")) {
+ ft = GNASH_FILETYPE_GIF;
+ }
+
+ // Read the image data.
+ boost::shared_ptr<IOChannel> ad(StreamAdapter::getFile(in,
in.get_tag_end_position()).release() );
- std::auto_ptr<GnashImage> im (ImageInput::readImageData(ad,
- GNASH_FILETYPE_JPEG));
+ std::auto_ptr<GnashImage> im (ImageInput::readImageData(ad, ft));
boost::intrusive_ptr<BitmapInfo> bi = render::createBitmapInfo(im);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11242: Read PNG and GIF data in DefineBits tags for all SWF versions (manually,
Benjamin Wolsey <=