These pure learningCodeNo practical use
Bitmap can replicate data faster than setpixel.
Static void main (string [] ARGs) {// screenshot code rectangle rec = screen. primaryscreen. bounds; bitmap IMG = new Bitmap (Rec. width, Rec. height); graphics gph = graphics. fromimage (IMG); gph. copyfromscreen (new point (0, 0), new point (0, 0), REC. size); // lock bitmap to system memory. drawing. imaging. bitmapdata bmp data = IMG. lockbits (REC, system. drawing. imaging. imagelockmode. readwrite, system. drawing. imaging. pixelformat. format16bpprgb555); // obtain the address of the starting row. intptr = BMP data. scan0; // defines an array to save bitmap data. int bytes = BMP data. stride * IMG. height; byte [] rgbvalues = new byte [bytes]; // copy the RGB value to the array system. runtime. interopservices. marshal. copy (PTR, rgbvalues, 0, bytes); IMG. unlockbits (BMP data); // copy the data to another bitmap. Bitmap img2 = new Bitmap (Rec. width, Rec. height); graphics gph2 = graphics. fromimage (img2); system. drawing. imaging. bitmapdata BMP data2 = img2.lockbits (REC, system. drawing. imaging. imagelockmode. readwrite, system. drawing. imaging. pixelformat. format16bpprgb555); intptr ptr2 = BMP data2.scan0; system. runtime. interopservices. marshal. copy (rgbvalues, 0, ptr2, bytes); img2.unlockbits (BMP data2); img2.save ("asd.jpg", system. drawing. imaging. imageformat. JPEG );}