OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return true; | 114 return true; |
115 } | 115 } |
116 | 116 |
117 bool PNGImageEncoder::encode(const SkBitmap& bitmap, Vector<unsigned char>* outp
ut) | 117 bool PNGImageEncoder::encode(const SkBitmap& bitmap, Vector<unsigned char>* outp
ut) |
118 { | 118 { |
119 SkAutoLockPixels bitmapLock(bitmap); | 119 SkAutoLockPixels bitmapLock(bitmap); |
120 | 120 |
121 if (bitmap.colorType() != kN32_SkColorType || !bitmap.getPixels()) | 121 if (bitmap.colorType() != kN32_SkColorType || !bitmap.getPixels()) |
122 return false; // Only support 32 bit/pixel skia bitmaps. | 122 return false; // Only support 32 bit/pixel skia bitmaps. |
123 | 123 |
| 124 if (bitmap.width() <= 0 || bitmap.height() <= 0) |
| 125 return false; // crbug.com/504690 |
| 126 |
124 return encodePixels(IntSize(bitmap.width(), bitmap.height()), static_cast<un
signed char*>(bitmap.getPixels()), true, output); | 127 return encodePixels(IntSize(bitmap.width(), bitmap.height()), static_cast<un
signed char*>(bitmap.getPixels()), true, output); |
125 } | 128 } |
126 | 129 |
127 bool PNGImageEncoder::encode(const ImageDataBuffer& imageData, Vector<unsigned c
har>* output) | 130 bool PNGImageEncoder::encode(const ImageDataBuffer& imageData, Vector<unsigned c
har>* output) |
128 { | 131 { |
129 if (!imageData.pixels()) | 132 if (!imageData.pixels()) |
130 return false; | 133 return false; |
131 | 134 |
132 return encodePixels(IntSize(imageData.width(), imageData.height()), imageDat
a.pixels(), false, output); | 135 return encodePixels(IntSize(imageData.width(), imageData.height()), imageDat
a.pixels(), false, output); |
133 } | 136 } |
134 | 137 |
135 } // namespace blink | 138 } // namespace blink |
OLD | NEW |