Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef INCLUDED_CANVAS_ICOLORBUFFER_HXX
21 : : #define INCLUDED_CANVAS_ICOLORBUFFER_HXX
22 : :
23 : : #include <sal/types.h>
24 : :
25 : : #include <boost/shared_ptr.hpp>
26 : :
27 : :
28 : : namespace canvas
29 : : {
30 : : /** Interface for a raw memory pixel container
31 : :
32 : : Use this interface to represent a surface of raw pixel (e.g. a
33 : : bitmap) to the canvas rendering framework.
34 : : */
35 : : struct IColorBuffer
36 : : {
37 : : /// The underlying pixel format for this buffer
38 : : enum Format
39 : : {
40 : : // 24-bit RGB pixel format, 8 bits per channel.
41 : : FMT_R8G8B8,
42 : :
43 : : // 32-bit ARGB pixel format with alpha, 8 bits per channel.
44 : : FMT_A8R8G8B8,
45 : :
46 : : // 32-bit RGB pixel format, 8 bits per channel.
47 : : FMT_X8R8G8B8,
48 : :
49 : : // for enum to 32bit
50 : : FMT_UNKNOWN = static_cast<sal_uInt32>(-1)
51 : : };
52 : :
53 [ # # ]: 0 : virtual ~IColorBuffer() {}
54 : :
55 : : /** Get a pointer to the raw memory bits of the pixel
56 : : */
57 : : virtual sal_uInt8* lock() const = 0;
58 : :
59 : : /** unlock previous locked buffer
60 : : */
61 : : virtual void unlock() const = 0;
62 : :
63 : : /** Get width in pixel
64 : : */
65 : : virtual sal_uInt32 getWidth() const = 0;
66 : :
67 : : /** Get height in pixel
68 : : */
69 : : virtual sal_uInt32 getHeight() const = 0;
70 : :
71 : : /** Offset, in bytes, between consecutive scan lines of the bitmap.
72 : : If the stride is positive, the bitmap is top-down.
73 : : If the stride is negative, the bitmap is bottom-up.
74 : : The returned value is only valid while the buffer is locked.
75 : : */
76 : : virtual sal_uInt32 getStride() const = 0;
77 : :
78 : : /** Get format of the color buffer
79 : : */
80 : : virtual Format getFormat() const = 0;
81 : : };
82 : :
83 : : typedef ::boost::shared_ptr< IColorBuffer > IColorBufferSharedPtr;
84 : : }
85 : :
86 : : #endif /* INCLUDED_CANVAS_ICOLORBUFFER_HXX */
87 : :
88 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|