skia_utils_ios.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef SKIA_EXT_SKIA_UTILS_IOS_H_
  5. #define SKIA_EXT_SKIA_UTILS_IOS_H_
  6. #include <CoreGraphics/CoreGraphics.h>
  7. #include <vector>
  8. #include "third_party/skia/include/core/SkBitmap.h"
  9. #include "third_party/skia/include/core/SkColor.h"
  10. #ifdef __OBJC__
  11. @class UIColor;
  12. @class UIImage;
  13. @class NSData;
  14. #else
  15. class UIColor;
  16. class UIImage;
  17. class NSData;
  18. #endif
  19. namespace skia {
  20. // Draws a CGImage into an SkBitmap of the given size.
  21. SK_API SkBitmap CGImageToSkBitmap(CGImageRef image,
  22. CGSize size,
  23. bool is_opaque);
  24. // Given an SkBitmap and a color space, return an autoreleased UIImage.
  25. SK_API UIImage* SkBitmapToUIImageWithColorSpace(const SkBitmap& skia_bitmap,
  26. CGFloat scale,
  27. CGColorSpaceRef color_space);
  28. // Decodes all image representations inside the data into a vector of SkBitmaps.
  29. // Returns a vector of all the successfully decoded representations or an empty
  30. // vector if none can be decoded.
  31. SK_API std::vector<SkBitmap> ImageDataToSkBitmaps(NSData* image_data);
  32. // Decodes all image representations inside the data into a vector of SkBitmaps.
  33. // If a representation is bigger than max_size (either width or height), it is
  34. // ignored.
  35. // Returns a vector of all the successfully decoded representations or an empty
  36. // vector if none can be decoded.
  37. SK_API std::vector<SkBitmap> ImageDataToSkBitmapsWithMaxSize(NSData* image_data,
  38. CGFloat max_size);
  39. // Returns a UIColor for an SKColor. Used by iOS downstream.
  40. SK_API UIColor* UIColorFromSkColor(SkColor color);
  41. } // namespace skia
  42. #endif // SKIA_EXT_SKIA_UTILS_IOS_H_