21 resource->
data = NULL;
29 int image_width,
int image_height,
int position_x,
int position_y)
36 size_t display_width = display->
width;
37 size_t display_height = display->
height;
38 int starting_position_x = position_x;
39 int starting_position_y = position_y;
43 size_t image_render_width = image_width;
44 size_t image_render_height = image_height;
49 int starting_col_in_image = offset_x;
52 if (starting_position_x < 0)
54 starting_col_in_image = -starting_position_x;
55 image_render_width += starting_position_x;
56 starting_position_x = 0;
58 else if (starting_position_x + image_render_width > display_width)
60 image_render_width = display_width - starting_position_x;
62 if (starting_position_y < 0)
65 image_render_height += starting_position_y;
66 starting_position_y = 0;
68 else if (starting_position_y + image_render_height > display_height)
70 image_render_height = display_height - starting_position_y;
74 if (image_render_width > 0 && image_render_height > 0)
76 int current_display_row = starting_position_y;
77 char* resourceRow = resource->
data + starting_col_in_image;
78 for (
size_t row = 0; row < image_render_height; ++row)
80 char* areaRow = display->
area[current_display_row];
81 for (
size_t col = 0; col < image_render_width; ++col)
83 areaRow[starting_position_x + col] = resourceRow[col];
85 current_display_row += 1;
86 resourceRow += resource->
numImages * image_width;
void BigResource_Render(Display *display, int bigResourceId, int offset_x, int image_width, int image_height, int position_x, int position_y)
Render the specified portion of the big resource into the given display at the given coordinates in t...
void BigResource_Clear(BigResource *resource)
Clear the BigResource object, freeing any memory associated with it.
Declaration of the BigResource structure along with the supporting BigResource_Clear function....
BigResource * BigResourceManager_GetResource(int bigResourceId)
Retrieve the requested big resource.
Declaration of the Big Resource Manager functions, BigResourceManager_Clear(), BigResourceManager_Add...
Represents a big image. Call the BigResource_Clear() function to release the memory used by each inst...
char * data
Image data, row-oriented.
int numImages
Number of images represented in the big image.
Represents a "display" window, in which to render Flyweight images. This "display" window is then pri...
int width
Width of each row.
int height
Height of each row.
char ** area
2-dimensional array of strings, representing rows. Each row is zero-terminated.