xbitcolourspacefrompalette.lua 732 B

12345678910111213
  1. -- Copyright 2010 Paulo Silva
  2. -- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. See <http://www.gnu.org/licenses/>
  3. w,h=getpicturesize();
  4. ok,bitd=inputbox("colourspace from palette","bitdepth:",4,1,8,5);
  5. if ok==true then
  6. bitd3=(2^bitd);bitd8=(2^(math.floor(bitd/2)));bitd9=(2^((math.floor((bitd-1)/2))+1))
  7. for y1=0,(bitd8-1),1 do
  8. for x1=0,(bitd9-1),1 do
  9. for y2=0,(bitd3-1),1 do
  10. for x2=0,(bitd3-1),1 do
  11. putpicturepixel(x1*bitd3+x2,y1*bitd3+y2,matchcolor((y2*255)/(bitd3-1),((y1*8+x1)*255)/(bitd3-1),(x2*255)/(bitd3-1)))
  12. end;end;end;end;end