CAIC (Cosmos, Advanced, Image, Converter) =D

Sep 28, 2011 at 6:05 PM
Edited Sep 28, 2011 at 6:07 PM

Hey Guys, Well I was trying to use that other cosmos image converter with a 27x29 image and it gave me 700 lines of code and the image was not drawn right at all. So I decided to contribute again. I have created a supper small Image converter that works perfect with cosmos. And it will even generate code so you can draw that image anywhere you want and it took 700 lines of code down to 50 or less! This is really cool. The only problem I found is that cosmos has some color offsets in the pallette's I think so you may find the colors a little off. But you can fix this really easy if you play with it. 

<Note: If you guys want to add this link to the home page feel free too>

The Page: www.caic.codeplex.com

My Image that was 700 lines now to this:

 

public static void Logo2(uint[] Arr, int width, int length, int xpixel, int ypixel)//This function draws the Array
{
uint x = 0, y = 0;
int texnumwid = 0;
int textnumlen = 0;
int i;
int t;
 int count = 0;
for (i = 0; i < length; i++)
{
for (t = 0; t < width; t++, count++)
{

VGAScreen.SetPaletteEntry(160160160,160,160,160);
if (Arr[count] == 160160160)
{
VGAScreen.SetPixel320x200x8(x + (uint)t + (uint)texnumwid + (uint)xpixel, y + (uint)i + (uint)textnumlen + (uint)ypixel, 160160160);
}
VGAScreen.SetPaletteEntry(173173173,173,173,173);
if (Arr[count] == 173173173)
{
VGAScreen.SetPixel320x200x8(x + (uint)t + (uint)texnumwid + (uint)xpixel, y + (uint)i + (uint)textnumlen + (uint)ypixel, 173173173);
}
VGAScreen.SetPaletteEntry(000,0,0,0);
if (Arr[count] == 000)
{
VGAScreen.SetPixel320x200x8(x + (uint)t + (uint)texnumwid + (uint)xpixel, y + (uint)i + (uint)textnumlen + (uint)ypixel, 000);
}
VGAScreen.SetPaletteEntry(223223223,223,223,223);
if (Arr[count] == 223223223)
{
VGAScreen.SetPixel320x200x8(x + (uint)t + (uint)texnumwid + (uint)xpixel, y + (uint)i + (uint)textnumlen + (uint)ypixel, 223223223);
}
VGAScreen.SetPaletteEntry(238238238,238,238,238);
if (Arr[count] == 238238238)
{
VGAScreen.SetPixel320x200x8(x + (uint)t + (uint)texnumwid + (uint)xpixel, y + (uint)i + (uint)textnumlen + (uint)ypixel, 238238238);
}
VGAScreen.SetPaletteEntry(150150150,150,150,150);
if (Arr[count] == 150150150)
{
VGAScreen.SetPixel320x200x8(x + (uint)t + (uint)texnumwid + (uint)xpixel, y + (uint)i + (uint)textnumlen + (uint)ypixel, 150150150);
}
VGAScreen.SetPaletteEntry(190190190,190,190,190);
if (Arr[count] == 190190190)
{
VGAScreen.SetPixel320x200x8(x + (uint)t + (uint)texnumwid + (uint)xpixel, y + (uint)i + (uint)textnumlen + (uint)ypixel, 190190190);
}
VGAScreen.SetPaletteEntry(193193193,193,193,193);
if (Arr[count] == 193193193)
{
VGAScreen.SetPixel320x200x8(x + (uint)t + (uint)texnumwid + (uint)xpixel, y + (uint)i + (uint)textnumlen + (uint)ypixel, 193193193);
}
}
}
}
public static uint[] Logo = {000,000,000,000,000,000,000,000,000,000,000,000,150150150,150150150,150150150,000,000,000,000,000,000,000,000,000,000,000,
                             000,000,000,000,000,000,000,000,000,000,000,150150150,150150150,190190190,190190190,190190190,150150150,150150150,000,000,000,000,000,000,000,000,000,
                             000,000,000,000,000,000,000,000,000,150150150,150150150,190190190,190190190,190190190,190190190,190190190,190190190,190190190,150150150,150150150,000,000,000,000,000,000,000,
                             000,000,000,000,000,000,000,150150150,150150150,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,150150150,150150150,000,000,000,000,000,
                             000,000,000,000,000,150150150,150150150,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,150150150,150150150,000,000,000,
                             000,000,000,150150150,150150150,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,150150150,150150150,000,
                             000,150150150,150150150,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,150150150,
                             150150150,150150150,160160160,223223223,223223223,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,223223223,223223223,173173173,
                             150150150,150150150,160160160,160160160,160160160,223223223,223223223,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,223223223,223223223,173173173,173173173,173173173,
                             150150150,150150150,160160160,160160160,160160160,160160160,160160160,223223223,223223223,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,190190190,223223223,223223223,173173173,173173173,173173173,173173173,173173173,
                             150150150,150150150,160160160,160160160,160160160,160160160,160160160,160160160,160160160,223223223,223223223,190190190,190190190,190190190,190190190,190190190,190190190,190190190,223223223,223223223,173173173,173173173,173173173,173173173,173173173,173173173,173173173,
                             150150150,150150150,160160160,193193193,193193193,160160160,160160160,160160160,160160160,160160160,160160160,223223223,223223223,190190190,190190190,190190190,223223223,223223223,173173173,173173173,173173173,173173173,173173173,173173173,173173173,238238238,238238238,
                             150150150,150150150,193193193,160160160,160160160,193193193,193193193,160160160,160160160,160160160,160160160,160160160,160160160,223223223,223223223,223223223,173173173,173173173,173173173,173173173,173173173,173173173,173173173,238238238,238238238,173173173,238238238,
                             150150150,150150150,193193193,160160160,160160160,160160160,160160160,193193193,160160160,160160160,160160160,160160160,160160160,160160160,223223223,173173173,173173173,173173173,173173173,173173173,173173173,238238238,238238238,173173173,173173173,173173173,238238238,
                             150150150,150150150,193193193,160160160,160160160,160160160,160160160,193193193,160160160,193193193,193193193,160160160,160160160,160160160,223223223,173173173,173173173,173173173,173173173,173173173,173173173,238238238,173173173,173173173,173173173,173173173,238238238,
                             150150150,150150150,193193193,160160160,160160160,160160160,160160160,193193193,160160160,193193193,160160160,193193193,193193193,160160160,223223223,173173173,173173173,238238238,238238238,173173173,173173173,238238238,173173173,173173173,173173173,238238238,238238238,
                             150150150,150150150,193193193,193193193,193193193,160160160,160160160,193193193,160160160,193193193,160160160,160160160,160160160,193193193,223223223,238238238,238238238,173173173,238238238,173173173,173173173,238238238,173173173,238238238,238238238,173173173,173173173,
                             150150150,150150150,193193193,160160160,160160160,193193193,193193193,160160160,160160160,193193193,160160160,160160160,160160160,160160160,223223223,238238238,173173173,173173173,238238238,173173173,173173173,238238238,238238238,173173173,238238238,173173173,173173173,
                             150150150,150150150,193193193,160160160,160160160,160160160,160160160,160160160,160160160,193193193,193193193,193193193,160160160,160160160,223223223,238238238,173173173,173173173,238238238,173173173,173173173,238238238,173173173,173173173,238238238,173173173,173173173,
                             150150150,150150150,193193193,160160160,160160160,160160160,160160160,160160160,160160160,193193193,160160160,160160160,193193193,193193193,223223223,238238238,173173173,173173173,238238238,173173173,173173173,238238238,173173173,173173173,173173173,238238238,238238238,
                             150150150,150150150,160160160,160160160,160160160,160160160,160160160,160160160,160160160,193193193,160160160,160160160,160160160,160160160,223223223,238238238,238238238,238238238,238238238,173173173,173173173,238238238,173173173,173173173,173173173,173173173,173173173,
                             150150150,150150150,160160160,160160160,160160160,160160160,160160160,160160160,160160160,193193193,193193193,193193193,160160160,160160160,223223223,238238238,173173173,173173173,238238238,173173173,173173173,173173173,173173173,173173173,173173173,173173173,173173173,
                             150150150,150150150,150150150,160160160,160160160,160160160,160160160,160160160,160160160,160160160,160160160,160160160,193193193,193193193,223223223,238238238,173173173,173173173,238238238,173173173,173173173,173173173,173173173,173173173,173173173,173173173,150150150,
                             150150150,000,000,150150150,150150150,160160160,160160160,160160160,160160160,160160160,160160160,160160160,160160160,160160160,223223223,173173173,173173173,173173173,238238238,173173173,173173173,173173173,173173173,173173173,150150150,150150150,000,
                             000,000,000,000,000,150150150,150150150,160160160,160160160,160160160,160160160,160160160,160160160,160160160,223223223,173173173,173173173,173173173,173173173,173173173,173173173,173173173,150150150,150150150,000,000,000,
                             000,000,000,000,000,000,000,150150150,150150150,160160160,160160160,160160160,160160160,160160160,223223223,173173173,173173173,173173173,173173173,173173173,150150150,150150150,000,000,000,000,000,
                             000,000,000,000,000,000,000,000,000,150150150,150150150,160160160,160160160,160160160,223223223,173173173,173173173,173173173,150150150,150150150,000,000,000,000,000,000,000,
                             000,000,000,000,000,000,000,000,000,000,000,150150150,150150150,160160160,223223223,173173173,150150150,150150150,000,000,000,000,000,000,000,000,000,
                             000,000,000,000,000,000,000,000,000,000,000,000,000,150150150,150150150,150150150,000,000,000,000,000,000,000,000,000,000,000,
                             000};

 

 

The best part is the program generated this and the image still looked exactly the same only a few colors where different. Enjoy! Yours Truly - Matt