blah38621 help?

Jun 24, 2011 at 8:55 AM

Hey blah38621, I am creating this discussion, because I have no other way to contact you. I created the save creen nd restore screen functions but if the length is bigger then the width or visa versa it deos not save or restore properly. I spent alot of time trying to fix this and no luck.. PLEASE HELP! Thanks - Matt.

 

Heres my current functions. 

 

  public static void SaveScreenS(uint xpos, uint ypos, int len, int width, Image image)
        {
            uint n = 0;


           
           

                for (uint x = 0; x < width; x++)
                {
                    for (uint y = 0; y < len; y++)
                    {

                        uint I = VGAScreen.GetPixel320x200x8(xpos + x, ypos + y);

                        image.SetPixel(x, y, I, n);

                        n += 1;


                    }
                   
                }
           
          

               
        }
        public static void RestoreScreenS(uint xpos, uint ypos, int len, int width, Image image)
        {
           
                   uint n = 0;
                 

                       for (uint x4 = 0; x4 < width; x4++)
                       {
                           for (uint y4 = 0; y4 < len; y4++)
                           {

                               uint I4 = image.GetPixel(x4, y4, n);

                               VGAScreen.SetPixel(xpos + x4, ypos + y4, I4);

                               n += 1;


                           }
                       }
                   

                 
                   

        }


<DRAWING CLASS>




using System;
using System.Collections.Generic;

using System.Text;

namespace FutrueAppleOsx
{
    class VGAScreenE
    {
       
    }
    class Image {
        private uint[] Data;
        /// <summary>
        /// The height of the image.
        /// </summary>
        private int Height;
        /// <summary>
        /// The width of the image.
        /// </summary>
        private int Width;
        public Image(int width, int height)
        {
            this.Width = width;
            this.Height = height;
            this.Data = new uint[(Height + 1) * (Width + 1)];
        }
        public uint GetPixel(uint x, uint y, uint n)
        {
            return this.Data[n];
        }
        public void SetPixel(uint x, uint y, uint p, uint n)
        {
            
            this.Data[n] = p;
        }
    }
}

Developer
Jun 24, 2011 at 5:30 PM

My advice, go look at the GetPixel, and SetPixel functions in Orvid.Graphics.Image again, as all your doing there is setting the first element in the array repeatidly.

Jun 24, 2011 at 6:38 PM

Ok I looked and reset the get pixel functions to what it was, but now if I run the code my os deos nothing after I call that function so something is wrong here. 

The Code 

  

public static Image simage = new Image(36,40);

Public static void GUI() {




 VGAScreen.SetMode320x200x8();

            VGAScreen.SetPaletteEntry(4, 0, 255, 0);//Green
            VGAScreen.SetPaletteEntry(0, 0x00, 0x00, 0x00); //Black          
            VGAScreen.SetPaletteEntry(1, 0xFF, 0xFF, 0xFF); //White            
            VGAScreen.SetPaletteEntry(2, 0x3C, 0x00, 0x00);//Red                                  
            VGAScreen.SetPaletteEntry(3, 74, 137, 240);//Blue          
            VGAScreen.SetPaletteEntry(5, 50, 50, 50);//Grey
            VGAScreen.SetPaletteEntry(6, 236, 233, 216);//window color
            VGAScreen.SetPaletteEntry(7, 255, 248, 106);//light yellow
            VGAScreen.SetPaletteEntry(8, 0, 90, 0);//Dark Green
 Mouse2.Initialize();//Initialize Mouse
SaveScreenS(10,10,36,40, simage);
            
           


            DrawRect(10, 10, 36, 40, 1); 


  SaveScreen(0, 0);
            DrawPointer(0, 0);
            
            MouseEnabled();//Call the mouse loop


}





<Drawing Class>







using System;
using System.Collections.Generic;

using System.Text;

namespace FutrueAppleOsx
{
    class VGAScreenE
    {
       
    }
    class Image {
        private uint[] Data;
        /// <summary>
        /// The height of the image.
        /// </summary>
        private int Height;
        /// <summary>
        /// The width of the image.
        /// </summary>
        private int Width;
        public Image(int width, int height)
        {
            this.Width = width;
            this.Height = height;
            this.Data = new uint[(Height + 1) * (Width + 1)];
        }
        public uint GetPixel(uint x, uint y, uint n)
        {
            return this.Data[(y * Width) + x];
        }
        public void SetPixel(uint x, uint y, uint p, uint n)
        {

            this.Data[((y * Width) + x)] = p;
        }
    }
}

Developer
Jun 25, 2011 at 12:48 AM

That would be because you aren't restoring the screen.

Jun 25, 2011 at 6:26 AM

No its ok, I figured it out blah38621. I was restoring it, just in another peace of code, like if I clicked something. I just reversed some code and made it work for me. Thanks for everything and all the help! I really appreciate all you do and wish I could be more like you. Thanks a TON!!!! Seriously, Thank you. Thanks - Matt