Image for server saving

This commit is contained in:
Simon Robertshaw
2011-06-09 17:53:41 +01:00
parent 74f613962e
commit 1effdb052a
4 changed files with 56 additions and 3 deletions

View File

@@ -48,6 +48,8 @@ extern unsigned int fire_alpha[CELL*3][CELL*3];
extern pixel *fire_bg;
extern pixel *pers_bg;
void draw_rgba_image(pixel *vid, unsigned char *data, int x, int y, float a);
void *ptif_pack(pixel *src, int w, int h, int *result_size);
pixel *ptif_unpack(void *datain, int size, int *w, int *h);

29
includes/images.h Normal file

File diff suppressed because one or more lines are too long

View File

@@ -3624,6 +3624,26 @@ pixel *render_packed_rgb(void *image, int width, int height, int cmp_size)
return res;
}
void draw_rgba_image(pixel *vid, unsigned char *data, int x, int y, float alpha)
{
unsigned char w, h;
int i, j;
unsigned char r, g, b, a;
w = *(data++)&0xFF;
h = *(data++)&0xFF;
for (j=0; j<h; j++)
{
for (i=0; i<w; i++)
{
r = *(data++)&0xFF;
g = *(data++)&0xFF;
b = *(data++)&0xFF;
a = *(data++)&0xFF;
drawpixel(vid, x+i, y+j, r, g, b, a*alpha);
}
}
}
void draw_image(pixel *vid, pixel *img, int x, int y, int w, int h, int a)
{
int i, j, r, g, b;

View File

@@ -15,6 +15,7 @@
#include <interface.h>
#include <misc.h>
#include <console.h>
#include <images.h>
SDLMod sdl_mod;
int sdl_key, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0;
@@ -1074,7 +1075,7 @@ int confirm_ui(pixel *vid_buf, char *top, char *msg, char *btn)
void login_ui(pixel *vid_buf)
{
int x0=(XRES-192)/2,y0=(YRES-80)/2,b=1,bq,mx,my,err;
int x0=(XRES+BARSIZE-192)/2,y0=(YRES+MENUSIZE-80)/2,b=1,bq,mx,my,err;
ui_edit ed1,ed2;
char *res;
@@ -1106,7 +1107,7 @@ void login_ui(pixel *vid_buf)
ed2.multiline = 0;
strcpy(ed2.str, "");
fillrect(vid_buf, -1, -1, XRES, YRES+MENUSIZE, 0, 0, 0, 192);
fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
while (!sdl_poll())
{
bq = b;
@@ -1575,6 +1576,8 @@ int save_name_ui(pixel *vid_buf)
cb.checked = svf_publish;
fillrect(vid_buf, -1, -1, XRES+BARSIZE, YRES+MENUSIZE, 0, 0, 0, 192);
draw_rgba_image(vid_buf, save_to_server_image, 0, 0, 0.7);
memcpy(old_vid, vid_buf, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);
while (!sdl_poll())
@@ -1617,7 +1620,6 @@ int save_name_ui(pixel *vid_buf)
ui_copytext_draw(vid_buf, &ctb);
ui_copytext_process(mx, my, b, bq, &ctb);
}
sdl_blit(0, 0, (XRES+BARSIZE), YRES+MENUSIZE, vid_buf, (XRES+BARSIZE));
memcpy(vid_buf, old_vid, ((XRES+BARSIZE)*(YRES+MENUSIZE))*PIXELSIZE);