I try to use the new WriteableBitmap in RTM Silverlight3, but I fail. all the examples and demos that I used to view and play during beta testing no longer work. I realized that they slightly changed the class interface, removing, for example, locking and release methods (which are still documented on the official pages of the document), as well as changing the constructor (no more than pixelformat as an argument, all bitmaps will be 32 bits from my understanding )
Has anyone managed to work with an example? There is a minimalist example here (I found it on some forum and changed it a bit); it does not work, the bitmap is not displayed
Yes, I call it .. there is a minimal example here (I found it on the net and changed it a bit); it does not work, I got a blank page (xaml contains one Image control named inputImage).
int imageWidth = 100;
int imageHeight = 100;
WriteableBitmap b = new WriteableBitmap(imageWidth, imageHeight);
for (int x = 0; x < imageWidth; x++)
{
for (int y = 0; y < imageHeight; y++)
{
byte[] components = new byte[4];
components[0] = (byte)(x % 255);
components[1] = (byte)(y % 255);
components[2] = (byte)(x * y % 255);
components[3] = 0;
int pixelValue = BitConverter.ToInt32(components, 0);
b.Pixels[y * imageWidth + x] = pixelValue;
}
}
b.Invalidate();
inputImage.Source = b;
Thanks for the help of Riccardo
source
share