1 /* 2 * Copyright (C) 2021 - 2022 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 ICC_PROFILE_INFO_H 17 #define ICC_PROFILE_INFO_H 18 19 #include <string> 20 #ifdef IMAGE_COLORSPACE_FLAG 21 #include "color_space.h" 22 #endif 23 #include "image_plugin_type.h" 24 #include "include/core/SkData.h" 25 #include "include/core/SkColorSpace.h" 26 #include "include/core/SkImageInfo.h" 27 #include "include/third_party/skcms/skcms.h" 28 #include "jpeg_utils.h" 29 #include "jpeglib.h" 30 #include "media_errors.h" 31 #include "src/images/SkImageEncoderFns.h" 32 namespace OHOS { 33 namespace ImagePlugin { 34 /* 35 * Class responsible for storing and parsing ICC profile information from JPEG 36 */ 37 class ICCProfileInfo { 38 public: 39 ICCProfileInfo(); 40 ~ICCProfileInfo(); 41 #ifdef IMAGE_COLORSPACE_FLAG 42 /** 43 * @brief get icc data. 44 * @param cinfo jpeg decompress pointer. 45 * @return parse result data. 46 */ 47 sk_sp<SkData> GetICCData(j_decompress_ptr cinfo); 48 49 /** 50 * @brief paser icc profile data form jpeg. 51 * @param cinfo jpeg decompress pointer. 52 * @return parse result data. 53 */ 54 uint32_t ParsingICCProfile(j_decompress_ptr cinfo); 55 56 /** 57 * @brief get graphiccolorspace info. 58 * @return SkColorSpace Object. 59 */ 60 OHOS::ColorManager::ColorSpace getGrColorSpace(); 61 62 /** 63 * @brief get whether ICC data exists in the current source 64 * @return is support icc profile or not. 65 */ 66 bool IsSupportICCProfile(); 67 68 /** 69 * @brief packing icc profile data 70 * @param cinfo jpeg decompress pointer. 71 * @param SkImageInfo. 72 * @return packing result data. 73 */ 74 uint32_t PackingICCProfile(j_compress_ptr cinfo, const SkImageInfo& info); 75 #endif 76 private: 77 #ifdef IMAGE_COLORSPACE_FLAG 78 OHOS::ColorManager::ColorSpace grColorSpace_ = 79 OHOS::ColorManager::ColorSpace(OHOS::ColorManager::ColorSpaceName::SRGB); 80 #endif 81 bool isSupportICCProfile_; 82 }; 83 } // namespace ImagePlugin 84 } // namespace OHOS 85 #endif // ICC_PROFILE_INFO_H 86