Advertisement
Guest User

pixel on bitmapsource

a guest
Feb 23rd, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. ERROR: Buffer size is not sufficient. I think it's my stride      
  2.        static void Main(string[] args)
  3.        {
  4.            List<System.Windows.Media.Color> colors = new List<System.Windows.Media.Color>();
  5.            colors.Add(System.Windows.Media.Colors.Red);
  6.            BitmapPalette palette = new BitmapPalette(colors);
  7.  
  8.  
  9.  
  10.            PixelFormat pf = PixelFormats.Indexed1;
  11.            int width = 16;
  12.            int height = 14;
  13.            int stride = width/pf.BitsPerPixel;
  14.  
  15.            byte[] pixels = new byte[28] { 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00 };
  16.  
  17.            BitmapSource image = BitmapSource.Create(width, height, 96, 96, pf, palette, pixels, stride);
  18.        }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement