aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkImageDecoder_CG.cpp
diff options
context:
space:
mode:
authorGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-04 21:46:08 +0000
committerGravatar scroggo@google.com <scroggo@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-04 21:46:08 +0000
commit5a7c6be72b940dde8ff6ad2485a09aecd56a2660 (patch)
treedae271d0e09ac6fcbb50dbc4509755055f20fc9c /src/ports/SkImageDecoder_CG.cpp
parent94bc60f9864094edbfb787b09c963d8818c8962f (diff)
Add the ability to provide function pointers to SkPicture serialization
and deserialization for encoding and decoding bitmaps. Remove kForceFlattenBitmapPixels_Flag, which is no longer used. When an SkOrderedReadBuffer needs to read a bitmap, if it does not have an image decoder, use a dummy bitmap. In GM, add a tolerance option for color differences, used when testing picture serialization, so it can assume two images are the same even though PNG encoding/decoding may have resulted in small differences. Create dummy implementations for SkImageDecoder and SkImageEncoder functions in SkImageDecoder_empty so that a project that does not want to include the images project it can still build. Allow ports to build without images project. In Mac's image encoder, copy 4444 to 8888 before encoding. Add SkWriter32::reservePad, to provide a pointer to write non 4 byte aligned data, padded with zeroes. In bench_ and render_ pictures, pass decode function to SkPicture creation from a stream. BUG=https://code.google.com/p/skia/issues/detail?id=842 Review URL: https://codereview.appspot.com/6551071 git-svn-id: http://skia.googlecode.com/svn/trunk@5818 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports/SkImageDecoder_CG.cpp')
-rw-r--r--src/ports/SkImageDecoder_CG.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp
index 3930c72f02..bcd3e3741c 100644
--- a/src/ports/SkImageDecoder_CG.cpp
+++ b/src/ports/SkImageDecoder_CG.cpp
@@ -150,12 +150,25 @@ private:
*/
bool SkImageEncoder_CG::onEncode(SkWStream* stream, const SkBitmap& bm,
int quality) {
+ // Used for converting a bitmap to 8888.
+ const SkBitmap* bmPtr = &bm;
+ SkBitmap bitmap8888;
+
CFStringRef type;
switch (fType) {
case kJPEG_Type:
type = kUTTypeJPEG;
break;
case kPNG_Type:
+ // PNG encoding an ARGB_4444 bitmap gives the following errors in GM:
+ // <Error>: CGImageDestinationAddImage image could not be converted to destination
+ // format.
+ // <Error>: CGImageDestinationFinalize image destination does not have enough images
+ // So instead we copy to 8888.
+ if (bm.getConfig() == SkBitmap::kARGB_4444_Config) {
+ bm.copyTo(&bitmap8888, SkBitmap::kARGB_8888_Config);
+ bmPtr = &bitmap8888;
+ }
type = kUTTypePNG;
break;
default:
@@ -168,7 +181,7 @@ bool SkImageEncoder_CG::onEncode(SkWStream* stream, const SkBitmap& bm,
}
SkAutoTCallVProc<const void, CFRelease> ardst(dst);
- CGImageRef image = SkCreateCGImageRef(bm);
+ CGImageRef image = SkCreateCGImageRef(*bmPtr);
if (NULL == image) {
return false;
}