Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

image_c Class Reference

Image class. More...

#include <image.h>

Inheritance diagram for image_c:

animation_c

Public Methods

virtual void create (ushort x, ushort y)
 create buffer

virtual bool load (const char *filename)
 load an image

void copy (image_c *src)
 copy image

void draw (ushort x, ushort y)
 draw image on screen

ushort get_width () const
 get image width

ushort get_height () const
 get image height

virtual const char * get_pixels () const
 get image pixel buffer

ulong get_buffer_len () const
 get image pixel buffer length

char get_bpp () const
 get image bit depth

bool get_has_alpha () const
 get image alpha flag

void stamp (image_c *src, sshort x, sshort y)
 stamp

void blt (image_c *src, sshort sx, sshort sy, sshort x, sshort y, sshort w, sshort h)
 stamp

void blt_blend (image_c *src, sshort sx, sshort sy, sshort x, sshort y, sshort w, sshort h, sshort blendtype)
 blit blend

void color_blend (image_c *src, sshort sx, sshort sy, sshort x, sshort y, sshort w, sshort h, color_t color)
 color blend

void crop (sshort x, sshort y, sshort w, sshort h)
 crop image

void set_pixel (sshort x, sshort y, color_t color)
 set a pixel

color_t get_pixel (sshort x, sshort y)
 get a pixel

void vline (sshort x, sshort y, sshort h, color_t color)
 draw vertical line

void hline (sshort x, sshort y, sshort w, color_t color)
 draw horizontal line

void line (sshort x, sshort y, sshort w, sshort h, color_t color)
 draw line

void rectangle (sshort x, sshort y, sshort w, sshort h, color_t color)
 draw rectangle

void filled_rectangle (sshort x, sshort y, sshort w, sshort h, color_t color)
 draw filled rectangle

sshort draw_char (sshort x, sshort y, uchar c, struct font_s *fnt, color_t color)
 draw character

sshort draw_string (sshort x, sshort y, const char *c, struct font_s *fnt, color_t color)
 draw string

void mirror_vertical ()
 mirror vertically

void rgb2yuv ()
 convert from rgb -> yuv

void yuv2rgb ()
 convert from yuv -> rgb


Protected Methods

bool load_tga_rgb (struct file_s *file)
 load rgb targa

bool load_tga_rgbrle (struct file_s *file)
 load rle-compressed rgb targa

bool load_tga (const char *filename)
 load a tga

bool prepare_blt (image_c *src, sshort &sx, sshort &sy, sshort &x, sshort &y, sshort &w, sshort &h)
 pepare blit coodinates


Protected Attributes

ushort width
 width of image

ushort height
 height of image

char * buf
 the image itself

ulong buflen
 size of image in size

bool hasalpha
 true if image contains alpha

char bpp
 bit depth


Detailed Description

This class contains a single 2d bitmap.

Definition at line 75 of file image.h.


Member Function Documentation

void blt image_c *    src,
sshort    sx,
sshort    sy,
sshort    x,
sshort    y,
sshort    w,
sshort    h
 

Alphablends image src onto this image centering it around x and y.

Parameters:
src  source image
sx  source x
sy  source y
x  destination x
y  destination y
w  width
h  height

Definition at line 215 of file x_image.cpp.

Referenced by uiwindow_c::paint(), uislider_c::paint(), and uicheckbutton_c::paint().

void blt_blend image_c *    src,
sshort    sx,
sshort    sy,
sshort    x,
sshort    y,
sshort    w,
sshort    h,
sshort    blendtype
 

Blends image src onto this image.

Parameters:
src  source image
sx  source x
sy  source y
x  destination x
y  destination y
w  width
h  height
blendtype  how to blend

Definition at line 253 of file x_image.cpp.

Referenced by uiobject_c::draw(), and uislider_c::paint().

void color_blend image_c *    src,
sshort    sx,
sshort    sy,
sshort    x,
sshort    y,
sshort    w,
sshort    h,
color_t    color
 

Blends the given color onto this image using the alpha channel from src. Used by font routines.

Parameters:
src  source image with alpha
sx  source x
sy  source y
x  destination x
y  destination y
w  width
h  height
color  color to blend

Definition at line 356 of file x_image.cpp.

void copy image_c *    src
 

Makes this imagea a copy of src.

Parameters:
src  source image

Definition at line 430 of file x_image.cpp.

References SafeDelete.

void create ushort    x,
ushort    y
[virtual]
 

Initializes the image by creating an empty buffer of the given size.

Parameters:
x  width
y  height

Definition at line 77 of file x_image.cpp.

References INVALID_INDEX, and SafeArrayDelete.

Referenced by uiobject_c::resize(), and animation_c::set_framecount().

void crop sshort    x,
sshort    y,
sshort    w,
sshort    h
 

Crops this image to the given rectangle.

Parameters:
x  left
y  top
w  new width
h  new height

Definition at line 457 of file x_image.cpp.

References SafeArrayDelete.

void draw ushort    x,
ushort    y
 

Blit's this image onto the screen. Be aware that this is pixel accurate but very slow. If you need speed instead of accuracy create a texture and set its bits to this image.

Parameters:
x  destination x
y  destination y

Definition at line 498 of file x_image.cpp.

References INVALID_INDEX.

Referenced by uiobject_c::draw().

sshort draw_char sshort    x,
sshort    y,
uchar    c,
struct font_s   fnt,
color_t    color
 

Draws a single character onto this image.

Parameters:
x  x position
y  y position
c  the character to draw
fnt  use this font
color  color

Definition at line 711 of file x_image.cpp.

References font_s::height, font_s::images, font_s::width, and font_s::widths.

sshort draw_string sshort    x,
sshort    y,
const char *    c,
struct font_s   fnt,
color_t    color
 

Draws a string on this image.

Parameters:
x  x position
y  y position
c  the string to draw
fnt  use this font
color  color

Definition at line 733 of file x_image.cpp.

Referenced by uiwindow_c::paint(), uilabel_c::paint(), uiedit_c::paint(), uicheckbutton_c::paint(), and uibutton_c::paint().

void filled_rectangle sshort    x,
sshort    y,
sshort    w,
sshort    h,
color_t    color
 

Draws a filled rectangle.

Parameters:
x  beginning x
y  beginning y
w  width
h  height
color  color to use

Definition at line 692 of file x_image.cpp.

Referenced by uiwindow_c::paint(), uiobject_c::paint(), and uiedit_c::paint().

color_t get_pixel sshort    x,
sshort    y
 

Gets a single pixel from this image.

void hline sshort    x,
sshort    y,
sshort    w,
color_t    color
 

Draws a simple horizontal line.

Parameters:
x  start position x
y  start position y
w  length of line
color  color of line

Definition at line 563 of file x_image.cpp.

Referenced by uiobject_c::paint().

void line sshort    x,
sshort    y,
sshort    w,
sshort    h,
color_t    color
 

Draws an arbitrary line.

Parameters:
x  beginning x
y  beginning y
w  width
h  height
color  color to use

Definition at line 592 of file x_image.cpp.

bool load const char *    filename [virtual]
 

Loads an image from file into the buffer.

Parameters:
filename  file name of image

Definition at line 98 of file x_image.cpp.

Referenced by gui_c::gui_c().

void mirror_vertical  
 

Mirrors this image vertically.

Definition at line 121 of file x_image.cpp.

References SafeArrayDelete.

bool prepare_blt image_c *    src,
sshort &    sx,
sshort &    sy,
sshort &    x,
sshort &    y,
sshort &    w,
sshort &    h
[protected]
 

Changes the coordinates so that the blit will fit both into this image and the source image. Returns true if any pixels would be transferred and false otherwise.

Parameters:
src  source bitmap
sx  source x
sy  source y
x  destination x
y  destination y
w  width
h  height

Definition at line 172 of file x_image.cpp.

void rectangle sshort    x,
sshort    y,
sshort    w,
sshort    h,
color_t    color
 

Draws a simple rectangle.

Parameters:
x  beginning x
y  beginning y
w  width
h  height
color  color to use

Definition at line 671 of file x_image.cpp.

Referenced by uiwindow_c::paint(), uiobject_c::paint(), uicheckbutton_c::paint(), and uibutton_c::paint().

void rgb2yuv  
 

Converts the image to yuv color space interpreting color values as rgb.

Definition at line 896 of file x_image.cpp.

void set_pixel sshort    x,
sshort    y,
color_t    color
 

Sets a single pixel in this image to color.

Parameters:
x  position x
y  position y
color  color

Definition at line 955 of file x_image.cpp.

void stamp image_c *    src,
sshort    x,
sshort    y
 

Alphablends image src onto this image centering it around x and y.

Parameters:
src  source bitmap
x  center coordinates x
y  center coordinates y

Definition at line 158 of file x_image.cpp.

void vline sshort    x,
sshort    y,
sshort    h,
color_t    color
 

Draws a simple vertical line.

Parameters:
x  start position x
y  start position y
h  length of line
color  color of line

Definition at line 533 of file x_image.cpp.

Referenced by uiobject_c::paint(), and uiedit_c::paint().

void yuv2rgb  
 

Converts the image to rgb color space interpreting color values as yuv.

Definition at line 925 of file x_image.cpp.


The documentation for this class was generated from the following files:
Generated on Wed Dec 18 15:48:49 2002 for omicron engine by doxygen1.2.18