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.
12 #include "sk_types_priv.h"
14 size_t sk_codec_min_buffered_bytes_needed()
16 return SkCodec::MinBufferedBytesNeeded();
19 sk_codec_t* sk_codec_new_from_stream(sk_stream_t* stream)
21 return ToCodec(SkCodec::NewFromStream(AsStream(stream)));
24 sk_codec_t* sk_codec_new_from_data(sk_data_t* data)
26 return ToCodec(SkCodec::NewFromData(AsData(data)));
29 void sk_codec_destroy(sk_codec_t* codec)
31 delete AsCodec(codec);
34 void sk_codec_get_info(sk_codec_t* codec, sk_imageinfo_t* info)
36 from_sk(AsCodec(codec)->getInfo(), info);
39 sk_codec_origin_t sk_codec_get_origin(sk_codec_t* codec)
41 return (sk_codec_origin_t)AsCodec(codec)->getOrigin();
44 void sk_codec_get_scaled_dimensions(sk_codec_t* codec, float desiredScale, sk_isize_t* dimensions)
46 *dimensions = ToISize(AsCodec(codec)->getScaledDimensions(desiredScale));
49 void sk_codec_get_valid_subset(sk_codec_t* codec, sk_irect_t* desiredSubset)
51 AsCodec(codec)->getValidSubset(AsIRect(desiredSubset));
54 sk_encoded_format_t sk_codec_get_encoded_format(sk_codec_t* codec)
56 return (sk_encoded_format_t)AsCodec(codec)->getEncodedFormat();
59 sk_codec_result_t sk_codec_get_pixels(sk_codec_t* codec, const sk_imageinfo_t* cinfo, void* pixels, size_t rowBytes, const sk_codec_options_t* coptions, sk_color_t ctable[], int* ctableCount)
62 from_c(*cinfo, &info);
63 SkCodec::Options options;
64 if (!from_c(*coptions, &options)) {
65 return INVALID_PARAMETERS_SK_CODEC_RESULT;
67 return (sk_codec_result_t)AsCodec(codec)->getPixels(info, pixels, rowBytes, &options, ctable, ctableCount);
70 sk_codec_result_t sk_codec_get_pixels_using_defaults(sk_codec_t* codec, const sk_imageinfo_t* cinfo, void* pixels, size_t rowBytes)
73 from_c(*cinfo, &info);
74 return (sk_codec_result_t)AsCodec(codec)->getPixels(info, pixels, rowBytes);