Help on Painting Bitmap?

Mar 13, 2012 at 11:34 PM

So, I tried painting a bitmap using COSMOS. As I found out, SetPalette() will change the color of every pixel already set, not the one that is about to be set. I added a counter to alternate the stored indexes. However, once the palette contains so many colors, the entire screen gets painted the next color in the sequence. Here is my example:

            int n = 1;
            for (int i = 0; i <= imgSplt.Length - 1; i++)
            {

                string[] pixl = imgSplt[i].Split(' ');
                byte[] c = { ConvertToByte(pixl[3]), ConvertToByte(pixl[4]), ConvertToByte(pixl[5]) };

                screen.SetPaletteEntry(n, ConvertToByte(pixl[3]), ConvertToByte(pixl[4]), ConvertToByte(pixl[5]));
                string str = n.ToString();
                screen.SetPixel320x200x8(ConvertToUint32(pixl[0]), ConvertToUint32(pixl[1]), ConvertToUint32(str));
                n += 1;
              
               
          
               }

Please note that imgSplit is a previously declared array and contains the integers required for the picture to paint. ConvertToByte() and ConvertToUint32() are declared as well. How can I write the above code without the entire screen being painted?

Mar 14, 2012 at 1:53 AM
Edited Mar 14, 2012 at 1:54 AM
Nickersoft wrote:

So, I tried painting a bitmap using COSMOS. As I found out, SetPalette() will change the color of every pixel already set, not the one that is about to be set. I added a counter to alternate the stored indexes. However, once the palette contains so many colors, the entire screen gets painted the next color in the sequence. Here is my example:

            int n = 1;
            for (int i = 0; i <= imgSplt.Length - 1; i++)
            {

                string[] pixl = imgSplt[i].Split(' ');
                byte[] c = { ConvertToByte(pixl[3]), ConvertToByte(pixl[4]), ConvertToByte(pixl[5]) };

                screen.SetPaletteEntry(n, ConvertToByte(pixl[3]), ConvertToByte(pixl[4]), ConvertToByte(pixl[5]));
                string str = n.ToString();
                screen.SetPixel320x200x8(ConvertToUint32(pixl[0]), ConvertToUint32(pixl[1]), ConvertToUint32(str));
                n += 1;
              
               
          
               }

Please note that imgSplit is a previously declared array and contains the integers required for the picture to paint. ConvertToByte() and ConvertToUint32() are declared as well. How can I write the above code without the entire screen being painted?

Well there is a option. In the VGA code there is a method called test mode. Its job is to set all the colors. So for example: 0xFF0000

if I call

VGA.SetPixel(0,0,0xFF0000);

Test mode will already have set that color. The color is 255,0,0 which is red by the way. So that will allow you to stop using the SetPallette method. Then you just make it use the images value like my CAIC does and bam. You can print out the image. 

Refrences: pearos.codeplex.com, CAIC is under downloads. Example images and other stuff is under Source > Core > Graphics > Images. And Source > Core > Screen > Drivers, and Screen.cs. Hope it helps - Matt

Mar 14, 2012 at 9:40 PM

I was with you up until "Then you just make it use the images value like my CAIC does and bam. You can print out the image." I currently have this line of code stuck in before my loop:

screen.TestMode320x200x8();

I believe this is what you were referring to? Although, it doesn't accept any arguments. Could you provide an example of what you're talking about?

 

Mar 14, 2012 at 10:11 PM
Nickersoft wrote:

I was with you up until "Then you just make it use the images value like my CAIC does and bam. You can print out the image." I currently have this line of code stuck in before my loop:

screen.TestMode320x200x8();

I believe this is what you were referring to? Although, it doesn't accept any arguments. Could you provide an example of what you're talking about?

 

CAIC is a program I wrote to convert images to code: http://pearos.codeplex.com/releases/view/83066

And use it to convert a image to code. Then use that code like I do here:

http://pearos.codeplex.com/SourceControl/changeset/view/11999#231100

Then just follow the code and you will understand. That array was gernerated by CAIC. Hope it helps - Matt

Mar 14, 2012 at 10:49 PM

I've already programmed an app to convert pictures into a decimal array. The problem with the code you gave me is:

Core.Screen.Screen.DrawFrame(StartButtonImage, 16, 16, x, y);

It doesn't exist in COSMOS. How do I achieve the above in COSMOS?
http://pearos.codeplex.com/releases/view/83066