| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkImageEncoder.h" | 8 #include "SkImageEncoder.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (NULL == scanline_import) { | 91 if (NULL == scanline_import) { |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| 94 | 94 |
| 95 SkAutoLockPixels alp(bitmap); | 95 SkAutoLockPixels alp(bitmap); |
| 96 const uint8_t* src = (uint8_t*)bitmap.getPixels(); | 96 const uint8_t* src = (uint8_t*)bitmap.getPixels(); |
| 97 if (NULL == bitmap.getPixels()) { | 97 if (NULL == bitmap.getPixels()) { |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 | 100 |
| 101 SkAutoLockColors ctLocker; | 101 const SkPMColor* colors = bitmap.getColorTable() ? bitmap.getColorTable()->r
eadColors() : NULL; |
| 102 const SkPMColor* colors = ctLocker.lockColors(bitmap); | |
| 103 | 102 |
| 104 const int argbStride = bitmap.width() * 4; | 103 const int argbStride = bitmap.width() * 4; |
| 105 SkAutoTDeleteArray<uint8_t> ada(new uint8_t[argbStride]); | 104 SkAutoTDeleteArray<uint8_t> ada(new uint8_t[argbStride]); |
| 106 uint8_t* argb = ada.get(); | 105 uint8_t* argb = ada.get(); |
| 107 for (int y = 0; y < bitmap.height(); ++y) { | 106 for (int y = 0; y < bitmap.height(); ++y) { |
| 108 scanline_import(src + y * bitmap.rowBytes(), argb, bitmap.width(), color
s); | 107 scanline_import(src + y * bitmap.rowBytes(), argb, bitmap.width(), color
s); |
| 109 stream->write(argb, argbStride); | 108 stream->write(argb, argbStride); |
| 110 } | 109 } |
| 111 | 110 |
| 112 return true; | 111 return true; |
| 113 } | 112 } |
| 114 | 113 |
| 115 | 114 |
| 116 /////////////////////////////////////////////////////////////////////////////// | 115 /////////////////////////////////////////////////////////////////////////////// |
| 117 DEFINE_ENCODER_CREATOR(ARGBImageEncoder); | 116 DEFINE_ENCODER_CREATOR(ARGBImageEncoder); |
| 118 /////////////////////////////////////////////////////////////////////////////// | 117 /////////////////////////////////////////////////////////////////////////////// |
| OLD | NEW |