Index: fileformat.doc ================================================================== --- fileformat.doc +++ fileformat.doc @@ -187,10 +187,13 @@ * 12 to 15 = Shift. The filter code is the direction: 12=up, 13=down, 14=right, 15=left. Follow by a list of pairs of shift amounts. The first byte of each pair is the shift amount; the high bit is set if this is the last pair. The second byte of each pair is the picture size that the shift amount is based on. + +* 16 = Hue/shade. The additional data is two bytes, being the hue adjust +(unsigned) and shade adjust (signed). === xclass/*.IMG === A picture; the part of the name before the dot is the picture name. Index: picedit.c ================================================================== --- picedit.c +++ picedit.c @@ -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: Index: picedit.doc ================================================================== --- picedit.doc +++ picedit.doc @@ -235,10 +235,14 @@ * Shift: Shift the picture. Specify the sizes and shift amounts in the format "size: shift"; each size also affects all multiples of that size, in which case the shift amount is also multiplied by the same amount. +* Hue/Shade: Specify hue adjustment and shade adjustment. The hue +adjustment is unsigned, and the shade adjustment is signed; any colours +that are in range 1 to 225 are affected; other colours remain unchanged. + === Multidependent pictures === A multidependent picture lump defines several pictures which are formed from one or more independent pictures and filters, using common sets of Index: picture.c ================================================================== --- picture.c +++ picture.c @@ -678,10 +678,28 @@ x=fgetc(fp); fgetc(fp); sz-=2; } break; + case 16: // Hue/shade + fread(buf,1,2,fp); + c=(Sint8)buf[1]; + sz-=2; + SDL_LockSurface(picts); + p=picts->pixels+((img&15)+picts->pitch*(img>>4))*picture_size; + for(y=0;y14) p[x]=15; else p[x]+=i; + } + } + p+=picts->pitch; + } + SDL_UnlockSurface(picts); + break; default: fprintf(stderr,"Unrecognized command in dependent picture (%d)\n",c); goto done; } if(sz<-1) fprintf(stderr,"Lump size of dependent picture is too short\n");