1 // Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // 30 // --------------------------------------------------------------------------- 31 // 32 // This file was generated by the CEF translator tool and should not edited 33 // by hand. See the translator.README.txt file in the tools directory for 34 // more information. 35 // 36 // $hash=b5a36ef39ff250c9d3cb1e9a8c7ee38d7e0f8b3f$ 37 // 38 39 #ifndef CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_ 40 #define CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_ 41 #pragma once 42 43 #include "include/capi/cef_base_capi.h" 44 #include "include/capi/cef_values_capi.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /// 51 // Container for a single image represented at different scale factors. All 52 // image representations should be the same size in density independent pixel 53 // (DIP) units. For example, if the image at scale factor 1.0 is 100x100 pixels 54 // then the image at scale factor 2.0 should be 200x200 pixels -- both images 55 // will display with a DIP size of 100x100 units. The functions of this 56 // structure can be called on any browser process thread. 57 /// 58 typedef struct _cef_image_t { 59 /// 60 // Base structure. 61 /// 62 cef_base_ref_counted_t base; 63 64 /// 65 // Returns true (1) if this Image is NULL. 66 /// 67 int(CEF_CALLBACK* is_empty)(struct _cef_image_t* self); 68 69 /// 70 // Returns true (1) if this Image and |that| Image share the same underlying 71 // storage. Will also return true (1) if both images are NULL. 72 /// 73 int(CEF_CALLBACK* is_same)(struct _cef_image_t* self, 74 struct _cef_image_t* that); 75 76 /// 77 // Add a bitmap image representation for |scale_factor|. Only 32-bit RGBA/BGRA 78 // formats are supported. |pixel_width| and |pixel_height| are the bitmap 79 // representation size in pixel coordinates. |pixel_data| is the array of 80 // pixel data and should be |pixel_width| x |pixel_height| x 4 bytes in size. 81 // |color_type| and |alpha_type| values specify the pixel format. 82 /// 83 int(CEF_CALLBACK* add_bitmap)(struct _cef_image_t* self, 84 float scale_factor, 85 int pixel_width, 86 int pixel_height, 87 cef_color_type_t color_type, 88 cef_alpha_type_t alpha_type, 89 const void* pixel_data, 90 size_t pixel_data_size); 91 92 /// 93 // Add a PNG image representation for |scale_factor|. |png_data| is the image 94 // data of size |png_data_size|. Any alpha transparency in the PNG data will 95 // be maintained. 96 /// 97 int(CEF_CALLBACK* add_png)(struct _cef_image_t* self, 98 float scale_factor, 99 const void* png_data, 100 size_t png_data_size); 101 102 /// 103 // Create a JPEG image representation for |scale_factor|. |jpeg_data| is the 104 // image data of size |jpeg_data_size|. The JPEG format does not support 105 // transparency so the alpha byte will be set to 0xFF for all pixels. 106 /// 107 int(CEF_CALLBACK* add_jpeg)(struct _cef_image_t* self, 108 float scale_factor, 109 const void* jpeg_data, 110 size_t jpeg_data_size); 111 112 /// 113 // Returns the image width in density independent pixel (DIP) units. 114 /// 115 size_t(CEF_CALLBACK* get_width)(struct _cef_image_t* self); 116 117 /// 118 // Returns the image height in density independent pixel (DIP) units. 119 /// 120 size_t(CEF_CALLBACK* get_height)(struct _cef_image_t* self); 121 122 /// 123 // Returns true (1) if this image contains a representation for 124 // |scale_factor|. 125 /// 126 int(CEF_CALLBACK* has_representation)(struct _cef_image_t* self, 127 float scale_factor); 128 129 /// 130 // Removes the representation for |scale_factor|. Returns true (1) on success. 131 /// 132 int(CEF_CALLBACK* remove_representation)(struct _cef_image_t* self, 133 float scale_factor); 134 135 /// 136 // Returns information for the representation that most closely matches 137 // |scale_factor|. |actual_scale_factor| is the actual scale factor for the 138 // representation. |pixel_width| and |pixel_height| are the representation 139 // size in pixel coordinates. Returns true (1) on success. 140 /// 141 int(CEF_CALLBACK* get_representation_info)(struct _cef_image_t* self, 142 float scale_factor, 143 float* actual_scale_factor, 144 int* pixel_width, 145 int* pixel_height); 146 147 /// 148 // Returns the bitmap representation that most closely matches |scale_factor|. 149 // Only 32-bit RGBA/BGRA formats are supported. |color_type| and |alpha_type| 150 // values specify the desired output pixel format. |pixel_width| and 151 // |pixel_height| are the output representation size in pixel coordinates. 152 // Returns a cef_binary_value_t containing the pixel data on success or NULL 153 // on failure. 154 /// 155 struct _cef_binary_value_t*(CEF_CALLBACK* get_as_bitmap)( 156 struct _cef_image_t* self, 157 float scale_factor, 158 cef_color_type_t color_type, 159 cef_alpha_type_t alpha_type, 160 int* pixel_width, 161 int* pixel_height); 162 163 /// 164 // Returns the PNG representation that most closely matches |scale_factor|. If 165 // |with_transparency| is true (1) any alpha transparency in the image will be 166 // represented in the resulting PNG data. |pixel_width| and |pixel_height| are 167 // the output representation size in pixel coordinates. Returns a 168 // cef_binary_value_t containing the PNG image data on success or NULL on 169 // failure. 170 /// 171 struct _cef_binary_value_t*(CEF_CALLBACK* get_as_png)( 172 struct _cef_image_t* self, 173 float scale_factor, 174 int with_transparency, 175 int* pixel_width, 176 int* pixel_height); 177 178 /// 179 // Returns the JPEG representation that most closely matches |scale_factor|. 180 // |quality| determines the compression level with 0 == lowest and 100 == 181 // highest. The JPEG format does not support alpha transparency and the alpha 182 // channel, if any, will be discarded. |pixel_width| and |pixel_height| are 183 // the output representation size in pixel coordinates. Returns a 184 // cef_binary_value_t containing the JPEG image data on success or NULL on 185 // failure. 186 /// 187 struct _cef_binary_value_t*(CEF_CALLBACK* get_as_jpeg)( 188 struct _cef_image_t* self, 189 float scale_factor, 190 int quality, 191 int* pixel_width, 192 int* pixel_height); 193 } cef_image_t; 194 195 /// 196 // Create a new cef_image_t. It will initially be NULL. Use the Add*() functions 197 // to add representations at different scale factors. 198 /// 199 CEF_EXPORT cef_image_t* cef_image_create(); 200 201 #ifdef __cplusplus 202 } 203 #endif 204 205 #endif // CEF_INCLUDE_CAPI_CEF_IMAGE_CAPI_H_ 206