OLD | NEW |
1 #include "SkBitmapScaler.h" | 1 #include "SkBitmapScaler.h" |
2 #include "SkBitmapFilter.h" | 2 #include "SkBitmapFilter.h" |
3 #include "SkRect.h" | 3 #include "SkRect.h" |
4 #include "SkTArray.h" | 4 #include "SkTArray.h" |
5 #include "SkErrorInternals.h" | 5 #include "SkErrorInternals.h" |
6 #include "SkConvolver.h" | 6 #include "SkConvolver.h" |
7 | 7 |
8 // SkResizeFilter --------------------------------------------------------------
-- | 8 // SkResizeFilter --------------------------------------------------------------
-- |
9 | 9 |
10 // Encapsulates computation and storage of the filters required for one complete | 10 // Encapsulates computation and storage of the filters required for one complete |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 destWidth, destHeight, destSubset, convolveProcs); | 289 destWidth, destHeight, destSubset, convolveProcs); |
290 | 290 |
291 // Get a source bitmap encompassing this touched area. We construct the | 291 // Get a source bitmap encompassing this touched area. We construct the |
292 // offsets and row strides such that it looks like a new bitmap, while | 292 // offsets and row strides such that it looks like a new bitmap, while |
293 // referring to the old data. | 293 // referring to the old data. |
294 const unsigned char* sourceSubset = | 294 const unsigned char* sourceSubset = |
295 reinterpret_cast<const unsigned char*>(source.getPixels()); | 295 reinterpret_cast<const unsigned char*>(source.getPixels()); |
296 | 296 |
297 // Convolve into the result. | 297 // Convolve into the result. |
298 SkBitmap result; | 298 SkBitmap result; |
299 result.setInfo(SkImageInfo::MakeN32(SkScalarCeilToInt(destSubset.width()), | 299 result.setConfig(SkImageInfo::MakeN32(SkScalarCeilToInt(destSubset.width()), |
300 SkScalarCeilToInt(destSubset.height()), | 300 SkScalarCeilToInt(destSubset.height())
, |
301 source.alphaType())); | 301 source.alphaType())); |
302 result.allocPixels(allocator, NULL); | 302 result.allocPixels(allocator, NULL); |
303 if (!result.readyToDraw()) { | 303 if (!result.readyToDraw()) { |
304 return false; | 304 return false; |
305 } | 305 } |
306 | 306 |
307 BGRAConvolve2D(sourceSubset, static_cast<int>(source.rowBytes()), | 307 BGRAConvolve2D(sourceSubset, static_cast<int>(source.rowBytes()), |
308 !source.isOpaque(), filter.xFilter(), filter.yFilter(), | 308 !source.isOpaque(), filter.xFilter(), filter.yFilter(), |
309 static_cast<int>(result.rowBytes()), | 309 static_cast<int>(result.rowBytes()), |
310 static_cast<unsigned char*>(result.getPixels()), | 310 static_cast<unsigned char*>(result.getPixels()), |
311 convolveProcs, true); | 311 convolveProcs, true); |
312 | 312 |
313 *resultPtr = result; | 313 *resultPtr = result; |
314 resultPtr->lockPixels(); | 314 resultPtr->lockPixels(); |
315 SkASSERT(NULL != resultPtr->getPixels()); | 315 SkASSERT(NULL != resultPtr->getPixels()); |
316 return true; | 316 return true; |
317 } | 317 } |
OLD | NEW |