How to display an int[] as a bitmap

Is there a possibillity to display an array of integers as a bitmap or is it only possible to display arrays of short as bitmaps (16bpp grayscale images)

Answer this question

How to display an int[] as a bitmap

  • Piyarit

    Try this

    Bitmap m = new Bitmap ( 100, 100 );

    Graphics g = Graphics.FromImage ( m );

    int[] i = new int[4];

    i[0]=1;

    i[1]=1;

    i[2]=1;

    i[3]=1;

    g.DrawString ( i[0].ToString (), this.Font, new SolidBrush ( Color.Red ), new PointF ( 0, 0 ) );



  • T2TD

    I've done some research on the web and it turned out that the Format16bppgrayscale is not working. So in the end I had to use Format8bppIndexed instead and then I know the drill.
  • pgmdsg

    You should be able to display any numeric array with some proper coding (as long as you know the width and height of the bitmap you want to display). What an int represents in that int[] array A pixel, that is, it is a 24 or 32 bit bitmap


  • How to display an int[] as a bitmap