A Simple menu function?

Jun 22, 2011 at 10:29 AM

Hey guys, not trying to be demanding. But I need some help on this. I spent all night on it and no luck. Anyway I was wondering if someone could write me a quick function so when I call it like this SaveScreem(X,Y,Length,Width); and it will save the screen at that position, and length and width, anyway then I need another quick function like this RestoreScreen(); and whatever the last screen save was it will restore it. Thats all I need. I did some up wit something similar and it failed =) So as a last resort I figured I would ask you nice people here. Thanks - Matt

Developer
Jun 22, 2011 at 6:13 PM
Edited Jun 22, 2011 at 6:15 PM

Well, aside from what Screams have to do with this :P, assuming your using a system similar to mine (aka. something image-based) (btw, i'd suggest updating to the newest version of Orvid.Graphics, as i fixed quite a few things in it), and you meant Screen, rather than Scream :P, this is a fairly simple thing to do, you need 3 fields,  1 is an image (i'll call it simage), and the saved x, and y position. (I'll call it sx, and sy respectivly).

Assuming that, the following psudo code should work:

SaveScreen(int xpos, int ypos, int len, int width)
simage = new Image(width, len);
sx = xpos;
sy = ypos;
for (int x = 0; x < width; x++)
{
for (int y = 0; y < len; y++)
{
simage.SetPixel(x,y, MainImage.GetPixel(xpos + x, ypos + y));
}
}

Then to restore it, simply draw the saved image at the saved x & y position.

Jun 22, 2011 at 7:16 PM
Edited Jun 22, 2011 at 7:33 PM
blah38621 wrote:

Well, aside from what Screams have to do with this :P, assuming your using a system similar to mine (aka. something image-based) (btw, i'd suggest updating to the newest version of Orvid.Graphics, as i fixed quite a few things in it), and you meant Screen, rather than Scream :P, this is a fairly simple thing to do, you need 3 fields,  1 is an image (i'll call it simage), and the saved x, and y position. (I'll call it sx, and sy respectivly).

Assuming that, the following psudo code should work:

SaveScreen(int xpos, int ypos, int len, int width)
simage = new Image(width, len);
sx = xpos;
sy = ypos;
for (int x = 0; x < width; x++)
{
for (int y = 0; y < len; y++)
{
simage.SetPixel(x,y, MainImage.GetPixel(xpos + x, ypos + y));
}
}

Then to restore it, simply draw the saved image at the saved x & y position.

Thanks for the reply blah38621, do I need a class for image? Or is it already in C# its kind of a dumb question but I was wondering. Anyway if thats all I need to do then that is awesome. I never thought of that. Great work! I won't be home for a while but when I do I will try to make this work. Anyway If need some extra help I'll let you know. Thanks - Matt

P.S. Yeah Scream was Ment to equal Screen, =d

Developer
Jun 22, 2011 at 8:04 PM

Image is the base type in my Orvid.Graphics system.

Jun 22, 2011 at 11:11 PM
Edited Jun 23, 2011 at 12:08 AM

Can you please send that to me? Thanks - Matt

Jun 23, 2011 at 1:30 AM
Edited Jun 23, 2011 at 1:50 AM
blah38621 wrote:

Well, aside from what Screams have to do with this :P, assuming your using a system similar to mine (aka. something image-based) (btw, i'd suggest updating to the newest version of Orvid.Graphics, as i fixed quite a few things in it), and you meant Screen, rather than Scream :P, this is a fairly simple thing to do, you need 3 fields,  1 is an image (i'll call it simage), and the saved x, and y position. (I'll call it sx, and sy respectivly).

Assuming that, the following psudo code should work:

SaveScreen(int xpos, int ypos, int len, int width)
simage = new Image(width, len);
sx = xpos;
sy = ypos;
for (int x = 0; x < width; x++)
{
for (int y = 0; y < len; y++)
{
simage.SetPixel(x,y, MainImage.GetPixel(xpos + x, ypos + y));
}
}

Then to restore it, simply draw the saved image at the saved x & y position.

Here is the code I cam up with:

 

public static Image simage;
        

        public static void SaveScreenS(uint xpos, uint ypos, int len, int width)
        {
            simage = new Image(width, len);
            sx = xpos;
            sy = ypos;
            for (uint x = 0; x <= width; x++)
            {
                for (uint y = 0; y <= len; y++)
                {
                    simage.SetPixel(x, y, VGAScreen.GetPixel320x200x8(xpos + x, ypos + y));
                }
            }
        }
        public static void RestoreScreenS(uint xpos, uint ypos, int len, int width)
        {
            simage = new Image(width, len);
            sx = xpos;
            sy = ypos;
            for (uint x = 0; x < width; x++)
            {
                for (uint y = 0; y < len; y++)
                {
                    
                    VGAScreen.SetPixel(x, y, simage.GetPixel(xpos + x, ypos + y));


                }
            }
        }



<IMAGE CLASS>



using System;
using System.Collections.Generic;

using System.Text;

namespace FutrueAppleOsx
{
    class VGAScreenE
    {
       
    }
    class Image {
        public uint[] Data;
        /// <summary>
        /// The height of the image.
        /// </summary>
        public int Height;
        /// <summary>
        /// The width of the image.
        /// </summary>
        public 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)
        {
            return Data[(y * Width) + x];
        }
        public void SetPixel(uint x, uint y, uint p)
        {
            //Modified.Add(new Vec2(x, y));
            Data[((y * Width) + x)] = p;
        }
    }
}

The only problem with it is it freazes if I can a save screen. Is this code correct? Thanks - Matt

Jun 23, 2011 at 7:56 PM

Nevermind, I got it to work. =D. Thanks for the starting code blah38621, I had to rewrite alot of it because of some issues but it now works! Thanks to you that is. So anyway thanks for all the help! Yours Truly - Matt