Where do the PixelFormats and WriteableBitmap.Lock go in Silverlight3?

A few months ago, I created several online samples, such as this one from Jeff Prosise , which uses the WriteableBitmap class in Silverlight.

By revising them today with the latest Silverlight3 installer (3.0.40624.0), the API seems to have changed.

I figured out some changes. For example, the AccessableBitmap property has disappeared, but I found it in the new Pixels property, so instead of writing:

 bmp[x]

I can write

bmp.Pixels[x]

Are there such simple replacements for these calls, or has the usage pattern changed?

bmp = new WriteableBitmap(width, height, PixelFormats.Bgr32);
bmp.Lock();
bmp.Unlock();

Can someone tell me a working example using the updated API?

+3
2

, Lock Unlock WritabelBitmap(int, int)? - ?

, SL3 Beta API . . " " (Silverlight 3)

+1

WriteableBitmap ... pbgra32, - , . , , , :

byte[] components = new byte[4];
components[0] = (byte)(blue % 256);       // blue
components[1] = (byte)(grn % 256);        // green
components[2] = (byte)(red % 256);        // red
components[3] = 0;                        // unused

:

byte[] components = new byte[4];
components[0] = (byte)(blue % 256);       // blue
components[1] = (byte)(grn % 256);        // green
components[2] = (byte)(red % 256);        // red
components[3] = 255;                      // alpha
+2

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


All Articles