1 /* 2 * Copyright (C) 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 ABS_IMAGE_ENCODER_H 17 #define ABS_IMAGE_ENCODER_H 18 19 #include "pixel_map.h" 20 #include "image_plugin_type.h" 21 #include "output_data_stream.h" 22 #include "plugin_service.h" 23 24 namespace OHOS { 25 namespace ImagePlugin { 26 struct PlEncodeOptions { 27 std::string format; 28 uint8_t quality = 100; 29 uint32_t numberHint = 1; 30 }; 31 32 class AbsImageEncoder { 33 public: 34 AbsImageEncoder() = default; 35 virtual ~AbsImageEncoder() = default; 36 virtual uint32_t StartEncode(OutputDataStream &outputStream, PlEncodeOptions &option) = 0; 37 virtual uint32_t AddImage(Media::PixelMap &pixelMap) = 0; 38 virtual uint32_t FinalizeEncode() = 0; 39 40 // define multiple subservices for this interface 41 static constexpr uint16_t SERVICE_DEFAULT = 0; 42 }; 43 } // namespace ImagePlugin 44 } // namespace OHOS 45 46 DECLARE_INTERFACE(OHOS::ImagePlugin::AbsImageEncoder, IMAGE_ENCODER_IID) 47 48 #endif // ABS_IMAGE_ENCODER_H 49