1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2014 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci// EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL EXPERIMENTAL 9cb93a386Sopenharmony_ci// DO NOT USE -- FOR INTERNAL TESTING ONLY 10cb93a386Sopenharmony_ci 11cb93a386Sopenharmony_ci#ifndef sk_image_DEFINED 12cb93a386Sopenharmony_ci#define sk_image_DEFINED 13cb93a386Sopenharmony_ci 14cb93a386Sopenharmony_ci#include "include/c/sk_types.h" 15cb93a386Sopenharmony_ci 16cb93a386Sopenharmony_ciSK_C_PLUS_PLUS_BEGIN_GUARD 17cb93a386Sopenharmony_ci 18cb93a386Sopenharmony_ci/** 19cb93a386Sopenharmony_ci * Return a new image that has made a copy of the provided pixels, or NULL on failure. 20cb93a386Sopenharmony_ci * Balance with a call to sk_image_unref(). 21cb93a386Sopenharmony_ci */ 22cb93a386Sopenharmony_ciSK_API sk_image_t* sk_image_new_raster_copy(const sk_imageinfo_t*, const void* pixels, size_t rowBytes); 23cb93a386Sopenharmony_ci 24cb93a386Sopenharmony_ci/** 25cb93a386Sopenharmony_ci * If the specified data can be interpreted as a compressed image (e.g. PNG or JPEG) then this 26cb93a386Sopenharmony_ci * returns an image. If the encoded data is not supported, returns NULL. 27cb93a386Sopenharmony_ci * 28cb93a386Sopenharmony_ci * On success, the encoded data may be processed immediately, or it may be ref()'d for later 29cb93a386Sopenharmony_ci * use. 30cb93a386Sopenharmony_ci */ 31cb93a386Sopenharmony_ciSK_API sk_image_t* sk_image_new_from_encoded(const sk_data_t* encoded); 32cb93a386Sopenharmony_ci 33cb93a386Sopenharmony_ci/** 34cb93a386Sopenharmony_ci * Encode the image's pixels and return the result as a new PNG in a 35cb93a386Sopenharmony_ci * sk_data_t, which the caller must manage: call sk_data_unref() when 36cb93a386Sopenharmony_ci * they are done. 37cb93a386Sopenharmony_ci * 38cb93a386Sopenharmony_ci * If the image type cannot be encoded, this will return NULL. 39cb93a386Sopenharmony_ci */ 40cb93a386Sopenharmony_ciSK_API sk_data_t* sk_image_encode(const sk_image_t*); 41cb93a386Sopenharmony_ci 42cb93a386Sopenharmony_ci/** 43cb93a386Sopenharmony_ci * Increment the reference count on the given sk_image_t. Must be 44cb93a386Sopenharmony_ci * balanced by a call to sk_image_unref(). 45cb93a386Sopenharmony_ci*/ 46cb93a386Sopenharmony_ciSK_API void sk_image_ref(const sk_image_t*); 47cb93a386Sopenharmony_ci/** 48cb93a386Sopenharmony_ci * Decrement the reference count. If the reference count is 1 before 49cb93a386Sopenharmony_ci * the decrement, then release both the memory holding the sk_image_t 50cb93a386Sopenharmony_ci * and the memory it is managing. New sk_image_t are created with a 51cb93a386Sopenharmony_ci reference count of 1. 52cb93a386Sopenharmony_ci*/ 53cb93a386Sopenharmony_ciSK_API void sk_image_unref(const sk_image_t*); 54cb93a386Sopenharmony_ci 55cb93a386Sopenharmony_ci/** 56cb93a386Sopenharmony_ci * Return the width of the sk_image_t/ 57cb93a386Sopenharmony_ci */ 58cb93a386Sopenharmony_ciSK_API int sk_image_get_width(const sk_image_t*); 59cb93a386Sopenharmony_ci/** 60cb93a386Sopenharmony_ci * Return the height of the sk_image_t/ 61cb93a386Sopenharmony_ci */ 62cb93a386Sopenharmony_ciSK_API int sk_image_get_height(const sk_image_t*); 63cb93a386Sopenharmony_ci 64cb93a386Sopenharmony_ci/** 65cb93a386Sopenharmony_ci * Returns a non-zero value unique among all images. 66cb93a386Sopenharmony_ci */ 67cb93a386Sopenharmony_ciSK_API uint32_t sk_image_get_unique_id(const sk_image_t*); 68cb93a386Sopenharmony_ci 69cb93a386Sopenharmony_ciSK_C_PLUS_PLUS_END_GUARD 70cb93a386Sopenharmony_ci 71cb93a386Sopenharmony_ci#endif 72