1 /* 2 * Copyright (C) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef INTERFACES_INNERKITS_INCLUDE_IMAGE_TYPE_H_ 17 #define INTERFACES_INNERKITS_INCLUDE_IMAGE_TYPE_H_ 18 19 #include <cinttypes> 20 21 namespace OHOS { 22 namespace Media { 23 #ifdef _WIN32 24 #define NATIVEEXPORT __declspec(dllexport) 25 #else 26 #define NATIVEEXPORT 27 #endif 28 29 enum class AllocatorType : int32_t { 30 // keep same with java AllocatorType 31 DEFAULT = 0, 32 HEAP_ALLOC = 1, 33 SHARE_MEM_ALLOC = 2, 34 CUSTOM_ALLOC = 3, // external 35 DMA_ALLOC = 4, // SurfaceBuffer 36 }; 37 38 enum class ColorSpace : int32_t { 39 // unknown color space. 40 UNKNOWN = 0, 41 42 // based on SMPTE RP 431-2-2007 & IEC 61966-2.1:1999. 43 DISPLAY_P3 = 1, 44 45 // standard Red Green Blue based on IEC 61966-2.1:1999. 46 SRGB = 2, 47 48 // SRGB with a linear transfer function based on IEC 61966-2.1:1999. 49 LINEAR_SRGB = 3, 50 51 // based on IEC 61966-2-2:2003. 52 EXTENDED_SRGB = 4, 53 54 // based on IEC 61966-2-2:2003. 55 LINEAR_EXTENDED_SRGB = 5, 56 57 // based on standard illuminant D50 as the white point. 58 GENERIC_XYZ = 6, 59 60 // based on CIE XYZ D50 as the profile conversion space. 61 GENERIC_LAB = 7, 62 63 // based on SMPTE ST 2065-1:2012. 64 ACES = 8, 65 66 // based on Academy S-2014-004. 67 ACES_CG = 9, 68 69 // based on Adobe RGB (1998). 70 ADOBE_RGB_1998 = 10, 71 72 // based on SMPTE RP 431-2-2007. 73 DCI_P3 = 11, 74 75 // based on Rec. ITU-R BT.709-5. 76 ITU_709 = 12, 77 78 // based on Rec. ITU-R BT.2020-1. 79 ITU_2020 = 13, 80 81 // based on ROMM RGB ISO 22028-2:2013. 82 ROMM_RGB = 14, 83 84 // based on 1953 standard. 85 NTSC_1953 = 15, 86 87 // based on SMPTE C. 88 SMPTE_C = 16, 89 }; 90 91 enum class EncodedFormat : int32_t { 92 UNKNOWN = 0, 93 JPEG = 1, 94 PNG = 2, 95 GIF = 3, 96 HEIF = 4, 97 }; 98 99 enum class PixelFormat : int32_t { 100 UNKNOWN = 0, 101 ARGB_8888 = 1, // Each pixel is stored on 4 bytes. 102 RGB_565 = 2, // Each pixel is stored on 2 bytes 103 RGBA_8888 = 3, 104 BGRA_8888 = 4, 105 RGB_888 = 5, 106 ALPHA_8 = 6, 107 RGBA_F16 = 7, 108 NV21 = 8, // Each pixel is sorted on 3/2 bytes. 109 NV12 = 9, 110 CMYK = 10, 111 RGBA_1010102 = 14, 112 }; 113 114 enum class AlphaType : int32_t { 115 IMAGE_ALPHA_TYPE_UNKNOWN = 0, 116 IMAGE_ALPHA_TYPE_OPAQUE = 1, // image pixels are stored as opaque. 117 IMAGE_ALPHA_TYPE_PREMUL = 2, // image have alpha component, and all pixels have premultiplied by alpha value. 118 IMAGE_ALPHA_TYPE_UNPREMUL = 3, // image have alpha component, and all pixels stored without premultiply alpha value. 119 }; 120 121 enum class MemoryUsagePreference : int32_t { 122 DEFAULT = 0, 123 LOW_RAM = 1, // low memory 124 }; 125 126 enum class FinalOutputStep : int32_t { 127 NO_CHANGE = 0, 128 CONVERT_CHANGE = 1, 129 ROTATE_CHANGE = 2, 130 SIZE_CHANGE = 3, 131 DENSITY_CHANGE = 4 132 }; 133 134 struct Position { 135 int32_t x = 0; 136 int32_t y = 0; 137 }; 138 139 struct Rect { 140 int32_t left = 0; 141 int32_t top = 0; 142 int32_t width = 0; 143 int32_t height = 0; 144 }; 145 146 struct Size { 147 int32_t width = 0; 148 int32_t height = 0; 149 }; 150 151 struct ImageInfo { 152 Size size; 153 PixelFormat pixelFormat = PixelFormat::UNKNOWN; 154 ColorSpace colorSpace = ColorSpace::SRGB; 155 AlphaType alphaType = AlphaType::IMAGE_ALPHA_TYPE_UNKNOWN; 156 int32_t baseDensity = 0; 157 int32_t stride = 1; 158 }; 159 160 struct DecodeOptions { 161 int32_t fitDensity = 0; 162 Rect CropRect; 163 Size desiredSize; 164 Rect desiredRegion; 165 float rotateDegrees = 0; 166 uint32_t rotateNewDegrees = 0; 167 static constexpr uint32_t DEFAULT_SAMPLE_SIZE = 1; 168 uint32_t sampleSize = DEFAULT_SAMPLE_SIZE; 169 PixelFormat desiredPixelFormat = PixelFormat::UNKNOWN; 170 AllocatorType allocatorType = AllocatorType::HEAP_ALLOC; 171 ColorSpace desiredColorSpace = ColorSpace::SRGB; 172 bool allowPartialImage = true; 173 bool editable = false; 174 MemoryUsagePreference preference = MemoryUsagePreference::DEFAULT; 175 }; 176 177 enum class ScaleMode : int32_t { 178 FIT_TARGET_SIZE = 0, 179 CENTER_CROP = 1, 180 }; 181 182 enum class IncrementalMode { FULL_DATA = 0, INCREMENTAL_DATA = 1 }; 183 } // namespace Media 184 } // namespace OHOS 185 186 #endif // INTERFACES_INNERKITS_INCLUDE_IMAGE_TYPE_H_ 187