2 * Copyright 2016 Xamarin Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "SkImageEncoder.h"
12 #include "sk_types_priv.h"
14 sk_data_t* sk_image_encode_specific(const sk_image_t* cimage, sk_image_encoder_t encoder, int quality) {
15 return ToData(AsImage(cimage)->encode((SkImageEncoder::Type)encoder, quality));
18 sk_image_t* sk_image_new_from_bitmap (const sk_bitmap_t* cbitmap)
20 return ToImage(SkImage::MakeFromBitmap(*AsBitmap(cbitmap)).release());
23 sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t* cinfo, const void* pixels,
26 from_c(*cinfo, &info);
27 return (sk_image_t*)SkImage::MakeRasterCopy(SkPixmap(info, pixels, rowBytes)).release();
30 sk_image_t* sk_image_new_from_encoded(const sk_data_t* cdata, const sk_irect_t* subset) {
31 return ToImage(SkImage::MakeFromEncoded(sk_ref_sp(AsData(cdata)),
32 reinterpret_cast<const SkIRect*>(subset)).release());
35 sk_data_t* sk_image_encode(const sk_image_t* cimage) {
36 return ToData(AsImage(cimage)->encode());
39 void sk_image_ref(const sk_image_t* cimage) {
40 AsImage(cimage)->ref();
43 void sk_image_unref(const sk_image_t* cimage) {
44 AsImage(cimage)->unref();
47 int sk_image_get_width(const sk_image_t* cimage) {
48 return AsImage(cimage)->width();
51 int sk_image_get_height(const sk_image_t* cimage) {
52 return AsImage(cimage)->height();
55 uint32_t sk_image_get_unique_id(const sk_image_t* cimage) {
56 return AsImage(cimage)->uniqueID();