summaryrefslogtreecommitdiffstats
path: root/fltk/fltk/PixelType.h
blob: 5e690dee2916ef3092b151c6cd2c5cb3b1fb7004 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// "$Id: PixelType.h 1399 2006-08-11 02:15:20Z spitzak $"
//
// Copyright 1998-2006 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "fltk-bugs@fltk.org".

#ifndef fltk_PixelType_h
#define fltk_PixelType_h

namespace fltk {

/// \name fltk/PixelType.h
//@{

/**
  Enumeration describing how colors are stored in an array of bytes
  that is a pixel. This is used as an argument for fltk::drawimage(),
  fltk::readimage(), and fltk::Image.

  Notice that the order of the bytes in memory of ARGB32 or RGB32 is
  a,r,g,b on a little-endian machine and b,g,r,a on a big-endian
  machine. Due to the use of these types by Windows, this is often
  the fastest form of data, if you have a choice. To convert an
  fltk::Color to RGB32, shift it right by 8 (for ARGB32 shift the
  alpha left 24 and or it in).

  More types may be added in the future. The set is as minimal as
  possible while still covering the types I have actually encountered.
*/
enum PixelType {
  MASK	= 0,	//!< 1 byte of inverted mask, filled with current color
  MONO	= 1,	//!< 1 byte of gray scale
  RGBx	= 2,	//!< bytes in r,g,b,a,r,g,b,a... order, a byte is ignored
  RGB	= 3, 	//!< bytes in r,g,b,r,g,b... order
  RGBA	= 4,	//!< bytes in r,g,b,a,r,g,b,a... order
  RGB32 = 5,	//!< 32-bit words containiing 0xaarrggbb (aa is ignored)
  ARGB32= 6,	//!< 32-bit words containing 0xaarrggbb
  // unpremulitplied is not yet implemented, acts like RGBA/ARGB32:
  RGBM	= 7,	//!< unpremultiplied bytes in r,g,b,a order
  MRGB32= 8	//!< unpremultiplied 0xaarrggbb
};

/**
   Turn a PixelType into the number of bytes needed to hold a pixel.
*/
inline int depth(PixelType t) {return (t<2 ? 1 : t==3 ? 3 : 4);}

//@}

}

#endif