1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Oracle Corporation code.
17 * The Initial Developer of the Original Code is Oracle Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 2005
19 * the Initial Developer. All Rights Reserved.
22 * Stuart Parmenter <pavlov@pavlov.net>
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef GFX_IMAGESURFACE_H
39 #define GFX_IMAGESURFACE_H
41 #include "gfxASurface.h"
44 // ARGB -- raw buffer.. wont be changed.. good for storing data.
47 * A raw image buffer. The format can be set in the constructor. Its main
48 * purpose is for storing read-only images and using it as a source surface,
49 * but it can also be drawn to.
51 class THEBES_API gfxImageSurface
: public gfxASurface
{
54 * Construct an image surface around an existing buffer of image data.
55 * @param aData A buffer containing the image data
56 * @param aSize The size of the buffer
57 * @param aStride The stride of the buffer
58 * @param format Format of the data
62 gfxImageSurface(unsigned char *aData
, const gfxIntSize
& aSize
,
63 long aStride
, gfxImageFormat aFormat
);
66 * Construct an image surface.
67 * @param aSize The size of the buffer
68 * @param format Format of the data
72 gfxImageSurface(const gfxIntSize
& size
, gfxImageFormat format
);
73 gfxImageSurface(cairo_surface_t
*csurf
);
75 virtual ~gfxImageSurface();
77 // ImageSurface methods
78 gfxImageFormat
Format() const { return mFormat
; }
80 const gfxIntSize
& GetSize() const { return mSize
; }
81 PRInt32
Width() const { return mSize
.width
; }
82 PRInt32
Height() const { return mSize
.height
; }
85 * Distance in bytes between the start of a line and the start of the
88 PRInt32
Stride() const { return mStride
; }
90 * Returns a pointer for the image data. Users of this function can
91 * write to it, but must not attempt to free the buffer.
93 unsigned char* Data() const { return mData
; } // delete this data under us and die.
95 * Returns the total size of the image data.
97 PRInt32
GetDataSize() const { return mStride
*mSize
.height
; }
99 /* Fast copy from another image surface; returns TRUE if successful, FALSE otherwise */
100 PRBool
CopyFrom (gfxImageSurface
*other
);
103 long ComputeStride() const;
107 unsigned char *mData
;
108 gfxImageFormat mFormat
;
112 #endif /* GFX_IMAGESURFACE_H */