tool to create a color fade table
authorhackbard <hackbard>
Thu, 6 Oct 2005 15:07:42 +0000 (15:07 +0000)
committerhackbard <hackbard>
Thu, 6 Oct 2005 15:07:42 +0000 (15:07 +0000)
create_color_table.c [new file with mode: 0644]

diff --git a/create_color_table.c b/create_color_table.c
new file mode 100644 (file)
index 0000000..aaa1e8c
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * unable to use gimp?
+ * me too!
+ *
+ */
+
+#include <stdio.h>
+#include "bmp.h"
+
+int main(int argc,char **argv) {
+
+       t_bmp bmp;
+       int i,j;
+       char val;
+       int off;
+
+       bmp_init(&bmp,2);
+
+       bmp.width=40;
+       bmp.height=120;
+       bmp.mode=WRITE;
+       if(argv[1][0]=='c') strcpy(bmp.file,"c-col.bmp");
+       else strcpy(bmp.file,"p-col.bmp");
+
+       bmp_alloc_map(&bmp);
+       
+       for(i=0;i<bmp.height;i++) {
+               if(argv[1][0]=='c') {
+                       for(j=0;j<bmp.width;j++) {
+                               off=i*bmp.width+j;
+                               val=i*255/bmp.height;
+                               bmp.map[off].r=val;
+                               bmp.map[off].g=val;
+                               bmp.map[off].b=0xff;
+                       }
+               } else {
+                       for(j=0;j<bmp.width;j++) {
+                               off=i*bmp.width+j;
+                               if(i<bmp.height/2) {
+                                       val=i*255/(bmp.height/2); 
+                                       bmp.map[off].b=val;
+                                       bmp.map[off].g=0;
+                                       bmp.map[off].g=0;
+                               } else {
+                                       val=(i-bmp.height/2)*255/(bmp.height/2);
+                                       bmp.map[off].b=0xff;
+                                       bmp.map[off].g=val;
+                                       bmp.map[off].b=0;
+                               }
+                       }
+
+               }
+       }
+
+       bmp_write_file(&bmp);
+
+       bmp_shutdown(&bmp);
+
+       return 1;
+}