Search code examples
c#.netbitmapwcf-ria-services

RIA Services method signature to pass Bitmap as a parameter?


I try to save a screenshot into the DB. But I cannot figure out the RIA Services method signature to do it. Any clue, please!

///////// Client Code /////////////////
    Graphics gfx;
            Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
            gfx = Graphics.FromImage(bmp);
            gfx.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
//////////////////////////////////////


[Invoke]
public void SaveScreen(?????)
{

}

Thank you!!!


Solution

  • The server code has to look like this:

    [Invoke]
    public void SaveScreen(byte[] image)
    {
        // Code to store the image in the database
    }
    

    For using this you just have to write the bitmap into an array of bytes (for example by saving it to a MemoryStream and invoking the stream's ToArray() method) and push it to the server.