screen.c File Reference

#include "libg15render.h"

Go to the source code of this file.

Functions

void g15r_clearScreen (g15canvas *canvas, int color)
 Fills the screen with pixels of color.
int g15r_getPixel (g15canvas *canvas, unsigned int x, unsigned int y)
 Gets the value of the pixel at (x, y).
void g15r_initCanvas (g15canvas *canvas)
 Clears the canvas and resets the mode switches.
void g15r_setPixel (g15canvas *canvas, unsigned int x, unsigned int y, int val)
 Sets the value of the pixel at (x, y).

Function Documentation

void g15r_clearScreen ( g15canvas canvas,
int  color 
)

Fills the screen with pixels of color.

Clears the screen and fills it with pixels of color

Parameters:
canvas A pointer to a g15canvas struct in which the buffer to be operated on is found.
color Screen will be filled with this color.

Definition at line 80 of file screen.c.

References g15canvas::buffer, and G15_BUFFER_LEN.

00081 {
00082   memset (canvas->buffer, (color ? 0xFF : 0), G15_BUFFER_LEN);
00083 }

int g15r_getPixel ( g15canvas canvas,
unsigned int  x,
unsigned int  y 
)

Gets the value of the pixel at (x, y).

Retrieves the value of the pixel at (x, y)

Parameters:
canvas A pointer to a g15canvas struct in which the buffer to be operated on is found.
x X offset for pixel to be retrieved.
y Y offset for pixel to be retrieved.

Definition at line 29 of file screen.c.

References g15canvas::buffer, BYTE_SIZE, G15_LCD_HEIGHT, and G15_LCD_WIDTH.

Referenced by g15r_pixelReverseFill(), and g15r_setPixel().

00030 {
00031   if (x >= G15_LCD_WIDTH || y >= G15_LCD_HEIGHT)
00032     return 0;
00033 
00034   unsigned int pixel_offset = y * G15_LCD_WIDTH + x;
00035   unsigned int byte_offset = pixel_offset / BYTE_SIZE;
00036   unsigned int bit_offset = 7 - (pixel_offset % BYTE_SIZE);
00037 
00038   return (canvas->buffer[byte_offset] & (1 << bit_offset)) >> bit_offset;
00039 }

void g15r_initCanvas ( g15canvas canvas  ) 

Clears the canvas and resets the mode switches.

Clears the screen and resets the mode values for a canvas

Parameters:
canvas A pointer to a g15canvas struct

Definition at line 91 of file screen.c.

References g15canvas::buffer, g15canvas::ftLib, G15_BUFFER_LEN, g15canvas::mode_cache, g15canvas::mode_reverse, and g15canvas::mode_xor.

00092 {
00093   memset (canvas->buffer, 0, G15_BUFFER_LEN);
00094   canvas->mode_cache = 0;
00095   canvas->mode_reverse = 0;
00096   canvas->mode_xor = 0;
00097 #ifdef TTF_SUPPORT
00098   if (FT_Init_FreeType (&canvas->ftLib))
00099     printf ("Freetype couldnt initialise\n");
00100 #endif
00101 }

void g15r_setPixel ( g15canvas canvas,
unsigned int  x,
unsigned int  y,
int  val 
)

Sets the value of the pixel at (x, y).

Sets the value of the pixel at (x, y)

Parameters:
canvas A pointer to a g15canvas struct in which the buffer to be operated on is found.
x X offset for pixel to be set.
y Y offset for pixel to be set.
val Value to which pixel should be set.

Definition at line 50 of file screen.c.

References g15canvas::buffer, BYTE_SIZE, G15_LCD_HEIGHT, G15_LCD_WIDTH, g15r_getPixel(), g15canvas::mode_reverse, and g15canvas::mode_xor.

Referenced by draw_ttf_char(), g15r_drawCircle(), g15r_drawIcon(), g15r_drawLine(), g15r_drawRoundBox(), g15r_drawSprite(), g15r_pixelBox(), g15r_pixelOverlay(), g15r_pixelReverseFill(), g15r_renderCharacterLarge(), g15r_renderCharacterMedium(), and g15r_renderCharacterSmall().

00051 {
00052   if (x >= G15_LCD_WIDTH || y >= G15_LCD_HEIGHT)
00053     return;
00054 
00055   unsigned int pixel_offset = y * G15_LCD_WIDTH + x;
00056   unsigned int byte_offset = pixel_offset / BYTE_SIZE;
00057   unsigned int bit_offset = 7 - (pixel_offset % BYTE_SIZE);
00058 
00059   if (canvas->mode_xor)
00060     val ^= g15r_getPixel (canvas, x, y);
00061   if (canvas->mode_reverse)
00062     val = !val;
00063 
00064   if (val)
00065     canvas->buffer[byte_offset] =
00066       canvas->buffer[byte_offset] | 1 << bit_offset;
00067   else
00068     canvas->buffer[byte_offset] =
00069       canvas->buffer[byte_offset] & ~(1 << bit_offset);
00070 
00071 }

Generated on Fri Dec 10 14:29:07 2010 for libg15render by  doxygen 1.6.3