[ create a new paste ] login | about

Link: http://codepad.org/DmPyhV8F    [ raw code | fork ]

aaronla - C++, pasted on Apr 23:
using System;
using System.Runtime.InteropServices;
using System.Drawing;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            long counter = 0;
            while (true)
            {
                try
                {
                    counter += 1;
                    // Create a new bitmap.
                    Bitmap bmp = new Bitmap(10, 10);

                    // Lock the bitmap's bits.  
                    Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
                    System.Drawing.Imaging.BitmapData bmpData =
                        bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,
                                     bmp.PixelFormat);

                    // Unlock the bits.
                    bmp.UnlockBits(bmpData);

                    // Get the address of the first line.
                    IntPtr ptr = bmpData.Scan0;

                    // Declare an array to hold the bytes of the bitmap.
                    int bytes = Math.Abs(bmpData.Stride)*bmp.Height;
                    byte[] rgbValues = new byte[bytes*1000];

                    // Copy the RGB values back to the bitmap
                    Marshal.Copy(rgbValues, 0, ptr, bytes*1000);
                }
                catch(Exception ex)
                {
                    Console.WriteLine( "Not crashed yet: {0} {1}", counter, ex.Message);
                }
            }
        }
    }
}


Create a new paste based on this one


Comments: