fix bitmapinfo
git-svn-id: http://skia.googlecode.com/svn/trunk@1744 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
292ade6625
commit
9c16bc020f
@ -11,14 +11,19 @@ static void SkBitmap_ReleaseInfo(void* info, const void* pixelData, size_t size)
|
||||
(SK_A32_SHIFT == (a) && SK_R32_SHIFT == (r) \
|
||||
&& SK_G32_SHIFT == (g) && SK_B32_SHIFT == (b))
|
||||
|
||||
static SkBitmap* prepareForImageRef(const SkBitmap& bm,
|
||||
static bool getBitmapInfo(const SkBitmap& bm,
|
||||
size_t* bitsPerComponent,
|
||||
CGBitmapInfo* info) {
|
||||
bool upscaleTo32 = false;
|
||||
CGBitmapInfo* info,
|
||||
bool* upscaleTo32) {
|
||||
if (upscaleTo32) {
|
||||
*upscaleTo32 = false;
|
||||
}
|
||||
|
||||
switch (bm.config()) {
|
||||
case SkBitmap::kRGB_565_Config:
|
||||
upscaleTo32 = true;
|
||||
if (upscaleTo32) {
|
||||
*upscaleTo32 = true;
|
||||
}
|
||||
// fall through
|
||||
case SkBitmap::kARGB_8888_Config:
|
||||
*bitsPerComponent = 8;
|
||||
@ -51,6 +56,16 @@ static SkBitmap* prepareForImageRef(const SkBitmap& bm,
|
||||
*info = kCGBitmapByteOrder16Little | kCGImageAlphaPremultipliedLast;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static SkBitmap* prepareForImageRef(const SkBitmap& bm,
|
||||
size_t* bitsPerComponent,
|
||||
CGBitmapInfo* info) {
|
||||
bool upscaleTo32;
|
||||
if (!getBitmapInfo(bm, bitsPerComponent, info, &upscaleTo32)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -178,9 +193,13 @@ bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output) {
|
||||
bitmap.allocPixels();
|
||||
bitmap.eraseColor(SK_ColorWHITE);
|
||||
|
||||
CGBitmapInfo info = kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst;
|
||||
size_t bitsPerComponent;
|
||||
CGBitmapInfo info;
|
||||
getBitmapInfo(bitmap, &bitsPerComponent, &info, NULL);
|
||||
|
||||
CGContextRef ctx = CGBitmapContextCreateWithData(bitmap.getPixels(),
|
||||
w, h, 8, bitmap.rowBytes(),
|
||||
w, h, bitsPerComponent,
|
||||
bitmap.rowBytes(),
|
||||
CGColorSpaceCreateDeviceRGB(),
|
||||
info, NULL, NULL);
|
||||
if (ctx) {
|
||||
|
Loading…
Reference in New Issue
Block a user