1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef INCLUDED_CANVAS_ICOLORBUFFER_HXX 25 #define INCLUDED_CANVAS_ICOLORBUFFER_HXX 26 27 #include <sal/types.h> 28 29 #include <boost/shared_ptr.hpp> 30 31 32 namespace canvas 33 { 34 /** Interface for a raw memory pixel container 35 36 Use this interface to represent a surface of raw pixel (e.g. a 37 bitmap) to the canvas rendering framework. 38 */ 39 struct IColorBuffer 40 { 41 /// The underlying pixel format for this buffer 42 enum Format 43 { 44 // 24-bit RGB pixel format, 8 bits per channel. 45 FMT_R8G8B8, 46 47 // 32-bit ARGB pixel format with alpha, 8 bits per channel. 48 FMT_A8R8G8B8, 49 50 // 32-bit RGB pixel format, 8 bits per channel. 51 FMT_X8R8G8B8, 52 53 // for enum to 32bit 54 FMT_UNKNOWN = static_cast<sal_uInt32>(-1) 55 }; 56 ~IColorBuffercanvas::IColorBuffer57 virtual ~IColorBuffer() {} 58 59 /** Get a pointer to the raw memory bits of the pixel 60 */ 61 virtual sal_uInt8* lock() const = 0; 62 63 /** unlock previous locked buffer 64 */ 65 virtual void unlock() const = 0; 66 67 /** Get width in pixel 68 */ 69 virtual sal_uInt32 getWidth() const = 0; 70 71 /** Get height in pixel 72 */ 73 virtual sal_uInt32 getHeight() const = 0; 74 75 /** Offset, in bytes, between consecutive scan lines of the bitmap. 76 If the stride is positive, the bitmap is top-down. 77 If the stride is negative, the bitmap is bottom-up. 78 The returned value is only valid while the buffer is locked. 79 */ 80 virtual sal_uInt32 getStride() const = 0; 81 82 /** Get format of the color buffer 83 */ 84 virtual Format getFormat() const = 0; 85 }; 86 87 typedef ::boost::shared_ptr< IColorBuffer > IColorBufferSharedPtr; 88 } 89 90 #endif /* INCLUDED_CANVAS_ICOLORBUFFER_HXX */ 91