1 /* 2 * Copyright (c) 2020-2021 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 GRAPHIC_LITE_IMAGE_LOAD_H 17 #define GRAPHIC_LITE_IMAGE_LOAD_H 18 19 #include "gfx_utils/image_info.h" 20 21 namespace OHOS { 22 enum CompressMode : uint8_t { 23 COMPRESS_MODE_NONE = 0, 24 COMPRESS_MODE__ZIP_ALG, 25 COMPRESS_MODE_BITMAP_ALG, 26 COMPRESS_MODE_BLOCK_ALG, 27 }; 28 29 class ImageLoad { 30 public: 31 static bool GetImageInfo(int32_t fd, uint32_t size, ImageInfo& imageInfo); 32 33 private: 34 ImageLoad() = delete; 35 ~ImageLoad() = delete; 36 37 static bool UnZip2ImageInfo(ImageInfo& imageInfo, uint8_t* buffer, uint32_t size); 38 static bool UncompressImageInZip(ImageInfo& imageInfo, uint8_t* buffer, uint32_t size); 39 static bool CreateImage(ImageInfo& imageInfo); 40 static bool Unzip24Image(uint8_t* imageBuffer, uint32_t size, ImageInfo& imageInfo); 41 static bool UnzipImage(uint8_t* imageBuffer, uint32_t size, ImageInfo& imageInfo); 42 }; 43 } // namespace OHOS 44 #endif // GRAPHIC_LITE_IMAGE_LOAD_H 45