(image.c) Cleanups

This commit is contained in:
twinaphex 2015-03-22 04:15:30 +01:00
parent 842d0aafa5
commit 326e7907ae

View File

@ -59,7 +59,7 @@ static bool rpng_image_load_argb_shift(const char *path,
{ {
uint32_t i; uint32_t i;
uint32_t num_pixels = out_img->width * out_img->height; uint32_t num_pixels = out_img->width * out_img->height;
uint32_t *pixels = (uint32_t*)out_img->pixels; uint32_t *pixels = (uint32_t*)out_img->pixels;
for (i = 0; i < num_pixels; i++) for (i = 0; i < num_pixels; i++)
{ {
@ -100,13 +100,13 @@ static bool rpng_image_load_argb_shift(const char *path,
static bool rpng_gx_convert_texture32(struct texture_image *image) static bool rpng_gx_convert_texture32(struct texture_image *image)
{ {
unsigned tmp_pitch, width2, i; unsigned tmp_pitch, width2, i;
const uint16_t *src; const uint16_t *src = NULL;
uint16_t *dst; uint16_t *dst = NULL;
/* Memory allocation in libogc is extremely primitive so try /* Memory allocation in libogc is extremely primitive so try
* to avoid gaps in memory when converting by copying over to * to avoid gaps in memory when converting by copying over to
* a temporary buffer first, then converting over into * a temporary buffer first, then converting over into
* main buffer again. */ * main buffer again. */
void *tmp = malloc(image->width * image->height * sizeof(uint32_t)); void *tmp = malloc(image->width * image->height * sizeof(uint32_t));
if (!tmp) if (!tmp)
{ {
@ -117,13 +117,11 @@ static bool rpng_gx_convert_texture32(struct texture_image *image)
memcpy(tmp, image->pixels, image->width * image->height * sizeof(uint32_t)); memcpy(tmp, image->pixels, image->width * image->height * sizeof(uint32_t));
tmp_pitch = (image->width * sizeof(uint32_t)) >> 1; tmp_pitch = (image->width * sizeof(uint32_t)) >> 1;
image->width &= ~3; image->width &= ~3;
image->height &= ~3; image->height &= ~3;
width2 = image->width << 1;
width2 = image->width << 1; src = (uint16_t*)tmp;
dst = (uint16_t*)image->pixels;
src = (uint16_t *) tmp;
dst = (uint16_t *) image->pixels;
for (i = 0; i < image->height; i += 4, dst += 4 * width2) for (i = 0; i < image->height; i += 4, dst += 4 * width2)
{ {
@ -158,11 +156,8 @@ void texture_image_free(struct texture_image *img)
bool texture_image_load(struct texture_image *out_img, const char *path) bool texture_image_load(struct texture_image *out_img, const char *path)
{ {
D3DXIMAGE_INFO m_imageInfo; D3DXIMAGE_INFO m_imageInfo;
d3d_video_t *d3d = NULL; driver_t *driver = driver_get_ptr();
driver_t *driver = driver_get_ptr(); d3d_video_t *d3d = (d3d_video_t*)driver->video_data;
d3d = (d3d_video_t*)driver->video_data;
out_img->vertex_buf = NULL; out_img->vertex_buf = NULL;
out_img->pixels = d3d_texture_new(d3d->dev, path, out_img->pixels = d3d_texture_new(d3d->dev, path,
@ -184,8 +179,8 @@ bool texture_image_load(struct texture_image *out_img, const char *path)
return false; return false;
} }
out_img->width = m_imageInfo.Width; out_img->width = m_imageInfo.Width;
out_img->height = m_imageInfo.Height; out_img->height = m_imageInfo.Height;
return true; return true;
} }