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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 SkASSERT(((RESIZE_FIRST_QUALITY_METHOD <= method) && | 257 SkASSERT(((RESIZE_FIRST_QUALITY_METHOD <= method) && |
258 (method <= RESIZE_LAST_QUALITY_METHOD)) || | 258 (method <= RESIZE_LAST_QUALITY_METHOD)) || |
259 ((RESIZE_FIRST_ALGORITHM_METHOD <= method) && | 259 ((RESIZE_FIRST_ALGORITHM_METHOD <= method) && |
260 (method <= RESIZE_LAST_ALGORITHM_METHOD))); | 260 (method <= RESIZE_LAST_ALGORITHM_METHOD))); |
261 | 261 |
262 SkRect dest = { 0, 0, destWidth, destHeight }; | 262 SkRect dest = { 0, 0, destWidth, destHeight }; |
263 if (!dest.contains(destSubset)) { | 263 if (!dest.contains(destSubset)) { |
264 SkErrorInternals::SetError( kInvalidArgument_SkError, | 264 SkErrorInternals::SetError( kInvalidArgument_SkError, |
265 "Sorry, the destination bitmap scale subset
" | 265 "Sorry, the destination bitmap scale subset
" |
266 "falls outside the full destination bitmap."
); | 266 "falls outside the full destination bitmap."
); |
| 267 return false; |
267 } | 268 } |
268 | 269 |
269 // If the size of source or destination is 0, i.e. 0x0, 0xN or Nx0, just | 270 // If the size of source or destination is 0, i.e. 0x0, 0xN or Nx0, just |
270 // return empty. | 271 // return empty. |
271 if (source.width() < 1 || source.height() < 1 || | 272 if (source.width() < 1 || source.height() < 1 || |
272 destWidth < 1 || destHeight < 1) { | 273 destWidth < 1 || destHeight < 1) { |
273 // todo: seems like we could handle negative dstWidth/Height, since that | 274 // todo: seems like we could handle negative dstWidth/Height, since that |
274 // is just a negative scale (flip) | 275 // is just a negative scale (flip) |
275 return false; | 276 return false; |
276 } | 277 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 SkBitmap SkBitmapScaler::Resize(const SkBitmap& source, | 324 SkBitmap SkBitmapScaler::Resize(const SkBitmap& source, |
324 ResizeMethod method, | 325 ResizeMethod method, |
325 float destWidth, float destHeight, | 326 float destWidth, float destHeight, |
326 SkBitmap::Allocator* allocator) { | 327 SkBitmap::Allocator* allocator) { |
327 SkBitmap result; | 328 SkBitmap result; |
328 if (!Resize(&result, source, method, destWidth, destHeight, allocator)) { | 329 if (!Resize(&result, source, method, destWidth, destHeight, allocator)) { |
329 return SkBitmap(); | 330 return SkBitmap(); |
330 } | 331 } |
331 return result; | 332 return result; |
332 } | 333 } |
OLD | NEW |