Gdc2.h File Reference

GDC v2.xx header. More...

#include <stdio.h>
#include "LgiOsDefs.h"
#include "LgiInc.h"
#include "LgiClass.h"
#include "Progress.h"
#include "GFile.h"
#include "GMem.h"
#include "Core.h"
#include "GContainers.h"
#include "GLibrary.h"
#include "GRect.h"
#include "GFont.h"
#include "GFilter.h"

Go to the source code of this file.

Classes

class  GdcPt2
 2d Point More...
class  GdcPt3
 3d Point More...
class  GdcRGB
 RGB Colour. More...
class  GPalette
 Array of RGB colours. More...
class  GApplicator
 Class to draw onto a memory bitmap. More...
class  GApplicatorFactory
 Creates applications from parameters. More...
class  GSurface
 Base class API for graphics operations. More...
class  GScreenDC
 An implemenation of GSurface to draw onto the screen. More...
class  GBlitRegions
 Blitting region helper class, can calculate the right source and dest rectangles for a blt operation including propagating clipping back to the source rect. More...
class  GMemDC
 An implemenation of GSurface to draw into a memory bitmap. More...
class  GPrintDC
 An implemenation of GSurface to print to a printer. More...
class  GdcDevice
 Main singleton graphics device class. Holds all global data for graphics rendering. More...
class  GInlineBmp
 Defines a bitmap inline in C++ code. More...
class  GReduceOptions
 Colour reduction options. More...

Defines

#define LGI_DEFAULT_GAMMA   1.0
 The default gamma curve (none) used by the gamma LUT GdcDevice::GetGamma.
#define LGI_PI   3.141592654
 The value of PI.
#define LGI_DegToRad(i)   ((i)*LGI_PI/180)
 Converts degrees to radians.
#define LGI_RadToDeg(i)   ((i)*180/LGI_PI)
 Converts radians to degrees.
#define GDC_SET   0
 Blending mode: overwrite.
#define GDC_AND   1
 Blending mode: bitwise AND with background.
#define GDC_OR   2
 Blending mode: bitwise OR with background.
#define GDC_XOR   3
 Blending mode: bitwise XOR with background.
#define GDC_ALPHA   4
 Blending mode: alpha blend with background.
#define GDC_FILL_TO_DIFFERENT   0
 GSurface::FloodFill to a different colour.
#define GDC_FILL_TO_BORDER   1
 GSurface::FloodFill to a certain colour.
#define GDC_FILL_NEAR   2
 GSurface::FloodFill while colour is near to the seed colour.
#define GDC_REDUCE_TYPE   0
 Used in GdcApp8Set::Blt when doing colour depth reduction to 8 bit.
#define REDUCE_NONE   0
 No conversion.
#define REDUCE_NEAREST   1
 Nearest colour pixels.
#define REDUCE_HALFTONE   2
 Halftone the pixels.
#define REDUCE_ERROR_DIFFUSION   3
 Error diffuse the pixels.
#define REDUCE_DL1   4
 Not used.
#define GDC_HALFTONE_BASE_INDEX   1
 Not used.
#define GDC_PALETTE_TYPE   2
 When in 8-bit defined the behaviour of GdcDevice::GetColour.
#define PALTYPE_ALLOC   0
 Allocate colours from the palette.
#define PALTYPE_RGB_CUBE   1
 Use an RGB cube.
#define PALTYPE_HSL   2
 Use a HSL palette.
#define GDC_PROMOTE_ON_LOAD   3
 Converts images to the specified bit-depth on load, does nothing if 0.
#define Rgb15(r, g, b)   ( ((r&0xF8)<<7) | ((g&0xF8)<<2) | ((b&0xF8)>>3))
 Create a 15bit COLOUR from components.
#define R15(c15)   ( (uchar) ((c15>>10)&0x1F) )
 Get the red component of a 15bit COLOUR.
#define G15(c15)   ( (uchar) ((c15>>5)&0x1F) )
 Get the green component of a 15bit COLOUR.
#define B15(c15)   ( (uchar) ((c15)&0x1F) )
 Get the blue component of a 15bit COLOUR.
#define Rgb16(r, g, b)   ( ((r&0xF8)<<8) | ((g&0xFC)<<3) | ((b&0xF8)>>3))
 Create a 16bit COLOUR from components.
#define R16(c16)   ( (uchar) ((c16>>11)&0x1F) )
 Get the red component of a 16bit COLOUR.
#define G16(c16)   ( (uchar) ((c16>>5)&0x3F) )
 Get the green component of a 16bit COLOUR.
#define B16(c16)   ( (uchar) ((c16)&0x1F) )
 Get the blue component of a 16bit COLOUR.
#define R24(c24)   ( ((c24)>>(C24R*8)) & 0xff )
 Get the red component of a 24bit COLOUR.
#define G24(c24)   ( ((c24)>>(C24G*8)) & 0xff )
 Get the green component of a 24bit COLOUR.
#define B24(c24)   ( ((c24)>>(C24B*8)) & 0xff )
 Get the blue component of a 24bit COLOUR.
#define Rgb24(r, g, b)   ( (((r)&0xFF) << (C24R*8)) | (((g)&0xFF) << (C24G*8)) | (((b)&0xFF) << (C24B*8)) )
 Create a 24bit COLOUR from components.
#define R32(c32)   ( (uchar) (c32 >> (C32R << 3)) )
 Get the red component of a 32bit COLOUR.
#define G32(c32)   ( (uchar) (c32 >> (C32G << 3)) )
 Get the green component of a 32bit COLOUR.
#define B32(c32)   ( (uchar) (c32 >> (C32B << 3)) )
 Get the blue component of a 32bit COLOUR.
#define A32(c32)   ( (uchar) (c32 >> (C32A << 3)) )
 Get the opacity/alpha component of a 32bit COLOUR.
#define Hls32(h, l, s)   ( ((h)<<16) | ((l)<<8) | (s) )
#define H32(c)   ( ((c)>>16)&0xFFFF )
#define L32(c)   ( ((c)>>8)&0xFF )
#define S32(c)   ( (c)&0xFF )
#define HUE_UNDEFINED   1024
#define HlsIsUndefined(Hls)   (H32(Hls) == HUE_UNDEFINED)

Typedefs

typedef uint32 COLOUR
 32bit colour of varing bit depth. If no associated depth is given, 32 bits is assumed.
typedef uint8 ALPHA
 Alpha value, 0 - transparent, 255 - solid.

Enumerations

enum  GColourReducePalette
 Colour reduction option to define what palette to go to.
enum  GColourReduceMatch
 Colour reduction option to define how to deal with reduction error.

Functions

LgiFunc COLOUR RgbToHls (COLOUR Rgb24)
LgiFunc COLOUR HlsToRgb (COLOUR Hsl32)
LgiFunc GSurfaceConvertDC (GSurface *pDC, int Bits)
 Converts a context to a different bit depth.
LgiFunc GSurfaceLoadDC (char *Name, bool UseOSLoader=true)
 Loads a image from a file.
LgiFunc bool WriteDC (char *Name, GSurface *pDC)
 Writes an image to a file.
LgiFunc COLOUR CBit (int DstBits, COLOUR c, int SrcBits=24, GPalette *Pal=0)
 Converts a colour to a different bit depth.
LgiFunc COLOUR GdcMixColour (COLOUR a, COLOUR b, double HowMuchA=0.5)
 blends 2 24bit colours by the amount specified
LgiFunc COLOUR GdcGreyScale (COLOUR c, int Bits=24)
 Turns a colour into an 8 bit grey scale representation.
LgiFunc bool GReduceBitDepth (GSurface *pDC, int Bits, GPalette *Pal=0, GReduceOptions *Reduce=0)
 Reduces a images colour depth.
LgiFunc void LgiFillGradient (GSurface *pDC, GRect &r, bool Vert, GArray< GColourStop > &Stops)
 Draws a horizontal or vertical gradient.


Detailed Description

GDC v2.xx header.

Author:
Matthew Allen
Date:
20/2/1997

Define Documentation

#define H32 (  )     ( ((c)>>16)&0xFFFF )

Extracts the hue component from the 32-bit HLS colour

See also:
Hls32

Referenced by HlsToRgb().

#define Hls32 ( h,
l,
 )     ( ((h)<<16) | ((l)<<8) | (s) )

Builds a complete 32bit HLS colour from it's components

The hue (H) component varies from 0 to 359 The lightness (L) component varies from 0 (black), thru 128 (colour) to 255 (white) The saturation (S) component varies from 0 (grey) thru to 255 (full colour)

See also:
HlsToRgb(), RgbToHls()

Referenced by RgbToHls().

#define HlsIsUndefined ( Hls   )     (H32(Hls) == HUE_UNDEFINED)

Returns true if the hue is undefined in a HLS color

See also:
Hls32

#define HUE_UNDEFINED   1024

The value of an undefined hue

See also:
Hls32

Referenced by RgbToHls().

#define L32 (  )     ( ((c)>>8)&0xFF )

Extracts the lightness component from the 32-bit HLS colour

See also:
Hls32

Referenced by HlsToRgb().

#define S32 (  )     ( (c)&0xFF )

Extracts the saturation component from the 32-bit HLS colour

See also:
Hls32

Referenced by HlsToRgb().


Typedef Documentation

typedef uint32 COLOUR

32bit colour of varing bit depth. If no associated depth is given, 32 bits is assumed.

    COLOUR typedef description
                31             24  23             16  15              8  7               0
                |-|-|-|-|-|-|-|-|  |-|-|-|-|-|-|-|-|  |-|-|-|-|-|-|-|-|  |-|-|-|-|-|-|-|-|

    Standard:
    8bit mode:  |------------------------ unused ---------------------|  |---- index ----|
    15bit mode: |----------------- unused ------------|T|-- red --|-- green ---|-- blue -|
    16bit mode: |------------- unused -------------|  |-- red --|--- green ----|-- blue -|
    24bit mode: |---- unused ---|  |----- blue ----|  |---- green ----|  |----- red -----|
    32bit mode: |---- alpha ----|  |----- blue ----|  |---- green ----|  |----- red -----|

Note: In 15bit mode the T bit can toggle between 8-bit indexing and RGB, or it can also just be a 1 bit alpha channel.


Function Documentation

LgiFunc GSurface* ConvertDC ( GSurface pDC,
int  Bits 
)

Converts a context to a different bit depth.

Parameters:
pDC  The source image
Bits  The destination bit depth

References GSurface::Blt(), GSurface::Create(), GSurface::X(), and GSurface::Y().

LgiFunc COLOUR HlsToRgb ( COLOUR  Hsl32  ) 

Converts a hls32 colour to a rgb24

See also:
Hls32

References H32, L32, Rgb24, and S32.

LgiFunc GSurface* LoadDC ( char *  Name,
bool  UseOSLoader = true 
)

Loads a image from a file.

This function uses the compiled in codecs, some of which require external shared libraries / DLL's to function. Other just need the right source to be compiled in.

Lgi comes with the following image codecs:

  • Windows or OS/2 Bitmap: GdcBmp (GFilter.cpp)
  • PCX: GdcPcx (Pcx.cpp)
  • GIF: GdcGif (Gif.cpp and Lzw.cpp)
  • JPEG: GdcJpeg (Jpeg.cpp + libjpeg library)
  • PNG: GdcPng (Png.cpp + libpng library)
Parameters:
Name  The full path of the file
UseOSLoader  [Optional] Enable OS based loaders

References GdcRGB::B, FILTER_CAP_READ, GdcRGB::G, GDC_OR, GDC_PROMOTE_ON_LOAD, GDC_SET, LgiSleep, GFile::Open(), GdcRGB::R, GFile::Read(), Rgb15, GFile::SetPos(), and GVariant::WStr().

Referenced by GBitmap::GBitmap(), GDefaultDocumentEnv::GetContent(), LgiLoadImageList(), GTrayIcon::Load(), and GToolBar::SetBitmap().

LgiFunc COLOUR RgbToHls ( COLOUR  Rgb24  ) 

Converts a rgb24 colour to a hls32

See also:
Hls32

References B24, G24, Hls32, HUE_UNDEFINED, and R24.


Generated on Wed Dec 1 15:41:00 2010 for Lgi by  doxygen 1.5.7.1