Draw_CreateImage: Set correct center.
This commit is contained in:
15
src/Draw.c
15
src/Draw.c
@@ -645,15 +645,14 @@ void Draw_OverrideExit(int override) { g_DrawExitOverride = override; }
|
|||||||
// Draw_CreateImage
|
// Draw_CreateImage
|
||||||
//
|
//
|
||||||
DrawImg Draw_CreateImage(int w, int h) {
|
DrawImg Draw_CreateImage(int w, int h) {
|
||||||
DrawImage image;
|
|
||||||
|
|
||||||
// Create the image container
|
// Create the image container
|
||||||
image = malloc(sizeof(TDrawImage));
|
DrawImage image = malloc(sizeof(TDrawImage));
|
||||||
image->data = malloc(w * h * 4);
|
image->data = malloc(w * h * 4);
|
||||||
image->x = 0;
|
|
||||||
image->y = 0;
|
|
||||||
image->w = w;
|
image->w = w;
|
||||||
image->h = h;
|
image->h = h;
|
||||||
|
image->x = -(image->w / 2);
|
||||||
|
image->y = -(image->h / 2);
|
||||||
image->flip = 0;
|
image->flip = 0;
|
||||||
image->tex = -1;
|
image->tex = -1;
|
||||||
|
|
||||||
@@ -665,18 +664,17 @@ DrawImg Draw_CreateImage(int w, int h) {
|
|||||||
//
|
//
|
||||||
// Loads an image, giving a reference.
|
// Loads an image, giving a reference.
|
||||||
DrawImg Draw_LoadImage(char *filename) {
|
DrawImg Draw_LoadImage(char *filename) {
|
||||||
DrawImage image;
|
|
||||||
|
|
||||||
// Try loading PNG images
|
// Try loading PNG images
|
||||||
if (EndsWith(filename, ".png") || EndsWith(filename, ".PNG")) {
|
if (EndsWith(filename, ".png") || EndsWith(filename, ".PNG")) {
|
||||||
image = malloc(sizeof(TDrawImage));
|
DrawImage image = malloc(sizeof(TDrawImage));
|
||||||
unsigned error = lodepng_decode32_file(&image->data, (unsigned *)&image->w, (unsigned *)&image->h, filename);
|
unsigned error = lodepng_decode32_file(&image->data, (unsigned *)&image->w, (unsigned *)&image->h, filename);
|
||||||
if (error) {
|
if (error) {
|
||||||
Print("Draw_LoadImage: PNG decoder error %u: %s on file %s\n", error, lodepng_error_text(error), filename);
|
Print("Draw_LoadImage: PNG decoder error %u: %s on file %s\n", error, lodepng_error_text(error), filename);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
image->x = -(int)(image->w / 2);
|
image->x = -(image->w / 2);
|
||||||
image->y = -(int)(image->h / 2);
|
image->y = -(image->h / 2);
|
||||||
image->flip = 0;
|
image->flip = 0;
|
||||||
image->tex = -1;
|
image->tex = -1;
|
||||||
return (DrawImg)image;
|
return (DrawImg)image;
|
||||||
@@ -1011,6 +1009,7 @@ DrawImage Draw_DefaultFontImage(const ColorRgba color) {
|
|||||||
|
|
||||||
// Create the image and colors
|
// Create the image and colors
|
||||||
img = Draw_CreateImage(8 * 256, 8);
|
img = Draw_CreateImage(8 * 256, 8);
|
||||||
|
Draw_SetOffset(img, 0, 0);
|
||||||
|
|
||||||
// Draw the font
|
// Draw the font
|
||||||
for (c = 0; c < 256; c++) {
|
for (c = 0; c < 256; c++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user