summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-02-15 12:23:52 +0000
committerSteve Block <steveblock@google.com>2010-02-16 11:48:32 +0000
commit8a0914b749bbe7da7768e07a7db5c6d4bb09472b (patch)
tree73f9065f370435d6fde32ae129d458a8c77c8dff /WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp
parentbf14be70295513b8076f3fa47a268a7e42b2c478 (diff)
downloadexternal_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.zip
external_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.tar.gz
external_webkit-8a0914b749bbe7da7768e07a7db5c6d4bb09472b.tar.bz2
Merge webkit.org at r54731 : Initial merge by git
Change-Id: Ia79977b6cf3b0b00c06ef39419989b28e57e4f4a
Diffstat (limited to 'WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp')
-rw-r--r--WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp b/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp
index dc120e3..7f00db2 100644
--- a/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp
+++ b/WebCore/platform/image-decoders/haiku/ImageDecoderHaiku.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2010 Stephan Aßmus, <superstippi@gmx.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,9 +33,41 @@ namespace WebCore {
NativeImagePtr RGBA32Buffer::asNewNativeImage() const
{
- BBitmap* bmp = new BBitmap(BRect(0, 0, width(), height()), B_RGB32);
- bmp->SetBits(m_bytes.data(), m_size.width() * m_size.height(), 0, B_RGB32);
- return bmp;
+ int bytesPerRow = width() * sizeof(PixelData);
+ OwnPtr<BBitmap> bitmap(new BBitmap(BRect(0, 0, width() - 1, height() - 1), 0, B_RGBA32, bytesPerRow));
+
+ const uint8* source = reinterpret_cast<const uint8*>(m_bytes.data());
+ uint8* destination = reinterpret_cast<uint8*>(bitmap->Bits());
+ int h = height();
+ int w = width();
+ for (int y = 0; y < h; y++) {
+#if 0
+// FIXME: Enable this conversion once Haiku has B_RGBA32P[remultiplied]...
+ memcpy(dst, source, bytesPerRow);
+#else
+ const uint8* sourceHandle = source;
+ uint8* destinationHandle = destination;
+ for (int x = 0; x < w; x++) {
+ if (sourceHandle[3] == 255 || !sourceHandle[3]) {
+ destinationHandle[0] = sourceHandle[0];
+ destinationHandle[1] = sourceHandle[1];
+ destinationHandle[2] = sourceHandle[2];
+ destinationHandle[3] = sourceHandle[3];
+ } else {
+ destinationHandle[0] = static_cast<uint16>(sourceHandle[0]) * 255 / sourceHandle[3];
+ destinationHandle[1] = static_cast<uint16>(sourceHandle[1]) * 255 / sourceHandle[3];
+ destinationHandle[2] = static_cast<uint16>(sourceHandle[2]) * 255 / sourceHandle[3];
+ destinationHandle[3] = sourceHandle[3];
+ }
+ destinationHandle += 4;
+ sourceHandle += 4;
+ }
+#endif
+ destination += bytesPerRow;
+ source += bytesPerRow;
+ }
+
+ return bitmap.release();
}
} // namespace WebCore