Hook up BMP image loading - color channels swapped - RGBA to ARGB

conversion won't work here
This commit is contained in:
twinaphex 2016-05-17 21:38:51 +02:00
parent 4309793b1d
commit 492dd59164
6 changed files with 36 additions and 3 deletions

View File

@ -37,7 +37,8 @@ enum video_image_format
IMAGE_FORMAT_NONE = 0,
IMAGE_FORMAT_TGA,
IMAGE_FORMAT_PNG,
IMAGE_FORMAT_JPEG
IMAGE_FORMAT_JPEG,
IMAGE_FORMAT_BMP
};
bool video_texture_image_set_color_shifts(
@ -175,6 +176,8 @@ static bool video_texture_image_load_internal(
#else
return false;
#endif
case IMAGE_TYPE_BMP:
break;
default:
break;
}
@ -243,6 +246,8 @@ static enum video_image_format video_texture_image_get_type(const char *path)
return IMAGE_FORMAT_PNG;
if (strstr(path, ".jpg") || strstr(path, ".jpeg"))
return IMAGE_FORMAT_JPEG;
if (strstr(path, ".bmp"))
return IMAGE_FORMAT_BMP;
return IMAGE_FORMAT_NONE;
}
@ -254,6 +259,8 @@ static enum image_type_enum video_texture_image_convert_fmt_to_type(enum video_i
return IMAGE_TYPE_PNG;
case IMAGE_FORMAT_JPEG:
return IMAGE_TYPE_JPEG;
case IMAGE_FORMAT_BMP:
return IMAGE_TYPE_BMP;
default:
case IMAGE_FORMAT_NONE:
break;
@ -302,6 +309,7 @@ bool video_texture_image_load(struct texture_image *out_img,
goto success;
#endif
break;
case IMAGE_FORMAT_BMP:
case IMAGE_FORMAT_PNG:
case IMAGE_FORMAT_JPEG:
if (video_texture_image_load_internal(

View File

@ -573,13 +573,16 @@ int rbmp_process_image(rbmp_t *rbmp, void **buf_data,
size_t size, unsigned *width, unsigned *height)
{
int comp;
#if 0
unsigned size_tex = 0;
#endif
if (!rbmp)
return IMAGE_PROCESS_ERROR;
rbmp->output_image = (uint32_t*)rbmp_load_from_memory(rbmp->buff_data, size, width, height, &comp, 4);
*buf_data = rbmp->output_image;
#if 0
size_tex = (*width) * (*height);
/* Convert RGBA to ARGB */
@ -592,6 +595,7 @@ int rbmp_process_image(rbmp_t *rbmp, void **buf_data,
unsigned int R = texel & 0x000000FF;
((unsigned int*)rbmp->output_image)[size_tex] = A | (R << 16) | G | (B >> 16);
}while(size_tex--);
#endif
return IMAGE_PROCESS_END;
}

View File

@ -8,6 +8,7 @@
#ifdef HAVE_RJPEG
#include <formats/rjpeg.h>
#endif
#include <formats/rbmp.h>
#include <formats/image.h>
@ -25,6 +26,9 @@ void image_transfer_free(void *data, enum image_type_enum type)
rjpeg_free((rjpeg_t*)data);
#endif
break;
case IMAGE_TYPE_BMP:
rbmp_free((rbmp_t*)data);
break;
case IMAGE_TYPE_NONE:
break;
}
@ -46,6 +50,8 @@ void *image_transfer_new(enum image_type_enum type)
#else
break;
#endif
case IMAGE_TYPE_BMP:
return rbmp_alloc();
default:
break;
}
@ -71,6 +77,8 @@ bool image_transfer_start(void *data, enum image_type_enum type)
return true;
#endif
break;
case IMAGE_TYPE_BMP:
return true;
case IMAGE_TYPE_NONE:
break;
}
@ -96,6 +104,8 @@ bool image_transfer_is_valid(
#else
break;
#endif
case IMAGE_TYPE_BMP:
return true;
case IMAGE_TYPE_NONE:
break;
}
@ -120,6 +130,9 @@ void image_transfer_set_buffer_ptr(
rjpeg_set_buf_ptr((rjpeg_t*)data, (uint8_t*)ptr);
#endif
break;
case IMAGE_TYPE_BMP:
rbmp_set_buf_ptr((rbmp_t*)data, (uint8_t*)ptr);
break;
case IMAGE_TYPE_NONE:
break;
}
@ -151,6 +164,9 @@ int image_transfer_process(
#else
break;
#endif
case IMAGE_TYPE_BMP:
return rbmp_process_image((rbmp_t*)data,
(void**)buf, len, width, height);
case IMAGE_TYPE_NONE:
break;
}
@ -175,6 +191,8 @@ bool image_transfer_iterate(void *data, enum image_type_enum type)
#else
break;
#endif
case IMAGE_TYPE_BMP:
return false;
case IMAGE_TYPE_NONE:
return false;
}

View File

@ -44,7 +44,8 @@ enum image_type_enum
{
IMAGE_TYPE_NONE = 0,
IMAGE_TYPE_PNG,
IMAGE_TYPE_JPEG
IMAGE_TYPE_JPEG,
IMAGE_TYPE_BMP
};
bool video_texture_image_set_color_shifts(unsigned *r_shift, unsigned *g_shift,

View File

@ -4011,7 +4011,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
break;
case DISPLAYLIST_IMAGES:
info->type_default = MENU_FILE_IMAGE;
strlcpy(info->exts, "png|jpg|jpeg", sizeof(info->exts));
strlcpy(info->exts, "png|jpg|jpeg|bmp", sizeof(info->exts));
break;
case DISPLAYLIST_AUDIO_FILTERS:
info->type_default = MENU_FILE_AUDIOFILTER;

View File

@ -364,6 +364,8 @@ bool rarch_task_push_image_load(const char *fullpath,
nbio->image_type = IMAGE_TYPE_PNG;
else if (strstr(fullpath, ".jpeg") || strstr(fullpath, ".jpg"))
nbio->image_type = IMAGE_TYPE_JPEG;
else if (strstr(fullpath, ".bmp"))
nbio->image_type = IMAGE_TYPE_BMP;
switch (cb_type_hash)
{