Skip to content

Instantly share code, notes, and snippets.

@cwensley
Last active August 29, 2015 14:02
Show Gist options
  • Save cwensley/162ca757311d22787a31 to your computer and use it in GitHub Desktop.
Save cwensley/162ca757311d22787a31 to your computer and use it in GitHub Desktop.
Set pixels directly in Eto.Drawing.Bitmap
var bitmap = new Bitmap(100, 100, PixelFormat.Format32bppRgb);
using (var bd = bitmap.Lock()) unsafe
{
int* val = (int*)bd.Data;
var pos = new Point(50, 50); // pixel we want to set
val += pos.X + (pos.Y * bd.ScanWidth / 4); // scanwidth is in bytes
*val = bd.TranslateArgbToData(Colors.Blue.ToArgb()); // translate argb to data format (may be different RGB order per platform)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment