mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-28 04:23:37 +01:00
fxlink: add (unused) scale parameter to SDL2 video capture
This commit is contained in:
parent
9f4d17ca4f
commit
45fd52444f
1 changed files with 24 additions and 8 deletions
|
@ -46,18 +46,31 @@ static void quit(void)
|
||||||
|
|
||||||
/* Generate an RGB888 surface from image data. */
|
/* Generate an RGB888 surface from image data. */
|
||||||
static SDL_Surface *surface_for_image(uint8_t **RGB888_rows, int width,
|
static SDL_Surface *surface_for_image(uint8_t **RGB888_rows, int width,
|
||||||
int height)
|
int height, int scale)
|
||||||
{
|
{
|
||||||
/* Little endian setup for RGB */
|
/* Little endian setup for RGB */
|
||||||
SDL_Surface *s = SDL_CreateRGBSurface(0, width, height, 24,
|
SDL_Surface *s = SDL_CreateRGBSurface(0, width*scale, height*scale, 24,
|
||||||
0x000000ff, 0x0000ff00, 0x0000ff00, 0);
|
0x000000ff, 0x0000ff00, 0x0000ff00, 0);
|
||||||
if(!s) {
|
if(!s) {
|
||||||
elog("cannot create surface for image\n");
|
elog("cannot create surface for image\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < height; i++)
|
for(int y = 0; y < height; y++) {
|
||||||
memcpy(s->pixels + i * s->pitch, RGB888_rows[i], width * 3);
|
for(int dy = 0; dy < scale; dy++) {
|
||||||
|
uint8_t *src = RGB888_rows[y];
|
||||||
|
uint8_t *dst = s->pixels + (y*scale+dy) * s->pitch;
|
||||||
|
for(int x = 0; x < width; x++) {
|
||||||
|
for(int dx = 0; dx < scale; dx++) {
|
||||||
|
dst[0] = src[0];
|
||||||
|
dst[1] = src[1];
|
||||||
|
dst[2] = src[2];
|
||||||
|
dst += 3;
|
||||||
|
}
|
||||||
|
src += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -68,11 +81,14 @@ void fxlink_sdl2_display_raw(struct fxlink_message_image_raw const *raw)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int current_w, current_h;
|
int current_w, current_h;
|
||||||
SDL_GetWindowSize(window, ¤t_w, ¤t_h);
|
int scale = 1;
|
||||||
if(current_w != raw->width || current_h != raw->height)
|
|
||||||
SDL_SetWindowSize(window, raw->width, raw->height);
|
|
||||||
|
|
||||||
SDL_Surface *src = surface_for_image(raw->data, raw->width, raw->height);
|
SDL_GetWindowSize(window, ¤t_w, ¤t_h);
|
||||||
|
if(current_w != raw->width * scale || current_h != raw->height * scale)
|
||||||
|
SDL_SetWindowSize(window, raw->width * scale, raw->height * scale);
|
||||||
|
|
||||||
|
SDL_Surface *src =
|
||||||
|
surface_for_image(raw->data, raw->width, raw->height, scale);
|
||||||
if(!src)
|
if(!src)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue