@@ -36,20 +36,27 @@ Uint8 shift[32]; Uint8 size[32]; Uint8 nshift; } ShiftFilter; +typedef struct { + Uint8 hue; + Sint8 shade; +} HueShadeFilter; + typedef struct { Uint8 code; // 0-7 = flip/rotations // 8-10 = change colours (8 is *->* *->* *->*; 9 is *->*->*->*->*; 10 is *<->* *<->* *<->*) // 11 = overlay // 12-15 = shift (up, down, right, left) + // 16 = hue/shade union { ColorFilter color; OverlayFilter overlay; ShiftFilter shift; + HueShadeFilter hueshade; }; } Filter; typedef struct { union { @@ -1180,10 +1187,14 @@ dp->filters[i].shift.size[k]=fgetc(fp); if(j&128) break; } dp->filters[i].shift.nshift=k+1; break; + case 16: + dp->filters[i].hueshade.hue=fgetc(fp); + dp->filters[i].hueshade.shade=(Sint8)fgetc(fp); + break; } } fclose(fp); } @@ -1205,10 +1216,14 @@ for(j=0;jfilters[i].shift.nshift;j++) { fputc(dp->filters[i].shift.shift[j]|(j==dp->filters[i].shift.nshift-1?128:0),fp); fputc(dp->filters[i].shift.size[j],fp); } break; + case 16: + fputc(dp->filters[i].hueshade.hue,fp); + fputc(dp->filters[i].hueshade.shade,fp); + break; } } } static int add_filter(DependentPicture*dp,const char*const*const txt,Sint8 c) { @@ -1215,16 +1230,16 @@ SDL_Rect r; SDL_Event ev; Uint8 f; char buf[4]=""; if(c<0 || dp->nfilters>63) return; - r.x=r.y=12; r.w=200; r.h=136; + r.x=r.y=12; r.w=200; r.h=144; set_cursor(XC_iron_cross); redraw: SDL_LockSurface(screen); SDL_FillRect(screen,&r,0xF8); - for(f=0;f<16;f++) { + for(f=0;f<17;f++) { buf[1]=f+'a'; draw_text(16,(f+2)<<3,buf,0xF8,0xFB); draw_text(48,(f+2)<<3,txt[f],0xF8,0xFF); } SDL_UnlockSurface(screen); @@ -1231,11 +1246,11 @@ SDL_Flip(screen); while(SDL_WaitEvent(&ev)) switch(ev.type) { case SDL_QUIT: exit(0); return 0; case SDL_KEYDOWN: if(ev.key.keysym.sym==SDLK_ESCAPE || ev.key.keysym.sym==SDLK_z) return 0; - if(ev.key.keysym.symSDLK_p) break; + if(ev.key.keysym.symSDLK_q) break; f=ev.key.keysym.sym-SDLK_a; goto found; case SDL_VIDEOEXPOSE: goto redraw; } found: @@ -1364,11 +1379,11 @@ case SDL_VIDEOEXPOSE: goto redraw; } } static void edit_dependent_picture(DependentPicture*dp,const char*name) { - static const char*const txt[16]={ + static const char*const txt[17]={ "Identity", "Flip \x1D", "Flip \x12", "Rotate 180\xF8", "Transpose", @@ -1381,10 +1396,11 @@ "Overlay", "Shift \x18", "Shift \x19", "Shift \x1A", "Shift \x1B", + "Hue/Shade", }; const char*s; char buf[64]; Sint8 c=-1; int i,j,y; @@ -1434,10 +1450,16 @@ for(j=0;jfilters[i].shift.nshift;j++) { snprintf(buf,64,"%d: %d",dp->filters[i].shift.size[j],dp->filters[i].shift.shift[j]); draw_text(32,y,buf,0xF0,0xFE); y+=8; } + break; + case 16: + draw_text(16,y,"Hue/Shade: ",0xF0,0xF7); + snprintf(buf,64,"%d %+d",dp->filters[i].hueshade.hue,dp->filters[i].hueshade.shade); + draw_text(104,y,buf,0xF0,0xFE); + y+=8; break; default: draw_text(16,y,"???",0xF0,0xFC); y+=8; break; @@ -1474,10 +1496,21 @@ s=screen_prompt("Name of overlay picture:"); if(s && *s) strncpy(dp->filters[c].overlay.name,s,63); break; case 12 ... 15: edit_shift_filter(&dp->filters[c].shift); + break; + case 16: + s=screen_prompt("Hue adjust:"); + if(s && *s) { + i=strtol(s,0,10); + s=screen_prompt("Shade adjust:"); + if(s && *s) { + dp->filters[c].hueshade.hue=i; + dp->filters[c].hueshade.shade=strtol(s,0,10); + } + } break; } } break; case SDLK_DELETE: case SDLK_KP_PERIOD: