Are Bitmap.LockBits and Graphics.FromImage combinable in C #

Can you combine the Bitmap.LockBits and Graphics.FromImage methods, or, in other words, if I have a "bmp" bitmap and want to edit the bitmap with the g graphic, these are the changes visible in the -array BitmapData.Scan0 byte :

Bitmap bmp = new Bitmap(200,200);
Graphics g = Graphics.FromImage(bmp);
bmp.LockBits(new Rectangle(0,0,200,200),
    ImageLockMode.ReadOnly,PixelFormat.Format32bppArgb);
byte* pixelData = (byte*) (void*) bmd.Scan0;
g.FillRectangle(Brushes.Red,new Rectangle(0,0,50,50));

Can I see the changes in PixelData after filling the red rectangle?

+3
source share
1 answer

, , , ImageLockMode LockBits.

+2

Source: https://habr.com/ru/post/1733018/


All Articles