private void OnePhoto_Click(object sender, EventArgs e) { ushort[] imageData = new ushort[288 * 384]; byte[] bArr = new byte[288 * 384]; Bitmap b = new Bitmap(384, 288, PixelFormat.Format8bppIndexed); ColorPalette ncp = b.Palette; Rectangle BoundsRect = new Rectangle(0, 0, 384, 288); BitmapData bmpData; IntPtr ptr; //put the image in black and white for (int i = 0; i < 256; i++) { ncp.Entries[i] = Color.FromArgb(255, i, i, i); } b.Palette = ncp; DLLHelper.RecvImage(imageData, 0); for (int n = 0; n < 288 * 384; n++) { bArr[n] = (byte)(imageData[n] >> 8); } bmpData = b.LockBits(BoundsRect, ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed); ptr = bmpData.Scan0; Marshal.Copy(bArr, 0, ptr, bmpData.Stride * 288); b.UnlockBits(bmpData); SaveImage(b); RefreshImage(b); //to do retrive the data from the CalcEntireTemp fonction }
private void Timer1_Tick(object sender, EventArgs e) { ushort[] imageData = new ushort[288 * 384]; byte[] bArr = new byte[288 * 384]; Bitmap b = new Bitmap(384, 288, PixelFormat.Format8bppIndexed); ColorPalette ncp = b.Palette; Rectangle BoundsRect = new Rectangle(0, 0, 384, 288); BitmapData bmpData; IntPtr ptr; for (int i = 0; i < 256; i++) { ncp.Entries[i] = Color.FromArgb(255, i, i, i); } b.Palette = ncp; DLLHelper.RecvImage(imageData, 0); for (int n = 0; n < 288 * 384; n++) { bArr[n] = (byte)(imageData[n] >> 8); } bmpData = b.LockBits(BoundsRect, ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed); ptr = bmpData.Scan0; Marshal.Copy(bArr, 0, ptr, bmpData.Stride * 288); b.UnlockBits(bmpData); SaveImage(b); RefreshImage(b); if (textBox1.Text.Equals("tick")) { textBox1.Text = "tack"; } else { textBox1.Text = "tick"; } }