YUVCanvas.h revision db205a1d75c1e9a7d0dbd8fa011335249ad6f4ac
1/* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17// YUVCanvas holds a reference to a YUVImage on which it can do various 18// drawing operations. It provides various utility functions for filling, 19// cropping, etc. 20 21 22#ifndef YUV_CANVAS_H_ 23 24#define YUV_CANVAS_H_ 25 26#include <stdint.h> 27 28namespace android { 29 30class YUVImage; 31class Rect; 32 33class YUVCanvas { 34public: 35 36 // Constructor takes in reference to a yuvImage on which it can do 37 // various drawing opreations. 38 YUVCanvas(YUVImage &yuvImage); 39 ~YUVCanvas(); 40 41 // Fills the entire image with the given YUV values. 42 void FillYUV(uint8_t yValue, uint8_t uValue, uint8_t vValue); 43 44 // Fills the rectangular region [startX,endX]x[startY,endY] with the given YUV values. 45 void FillYUVRectangle(const Rect& rect, 46 uint8_t yValue, uint8_t uValue, uint8_t vValue); 47 48 // Copies the region [startX,endX]x[startY,endY] from srcImage into the 49 // canvas' target image (mYUVImage) starting at 50 // (destinationStartX,destinationStartY). 51 // Note that undefined behavior may occur if srcImage is same as the canvas' 52 // target image. 53 void CopyImageRect( 54 const Rect& srcRect, 55 int32_t destStartX, int32_t destStartY, 56 const YUVImage &srcImage); 57 58private: 59 YUVImage& mYUVImage; 60 61 YUVCanvas(const YUVCanvas &); 62 YUVCanvas &operator=(const YUVCanvas &); 63}; 64 65} // namespace android 66 67#endif // YUV_CANVAS_H_ 68