Hi all
I'm trying to use the new WriteableBitmap in the Silverlight3 RTM, but I'm failing .. all the examples and demo I've used to look at and played with during the beta are no more working. I understood they've changed slightly the class interface, removing for example the Lock and Release methods (that are still documented in the official doc pages) and also changing the constructor (no more pixelformat as an argument, all the bitmap will be 32bit from my understanding).
Anyone managed to have an example working? Here there is a minimalistic example (I've found it in some forum and slightly modified it); it does not work, there is no bitmap displayed
Yes, I'm calling it .. here there is a minimal example (I've found around on the net and slightly modified it); it does not work, I got a blank page (the xaml contains a single Image control named inputImage).
int imageWidth = 100;
int imageHeight = 100;
//Create the bitmap
WriteableBitmap b = new WriteableBitmap(imageWidth, imageHeight);
for (int x = 0; x < imageWidth; x++)
{
for (int y = 0; y < imageHeight; y++)
{
// generate a color in 32bit format
byte[] components = new byte[4];
components[0] = (byte)(x % 255); // blue
components[1] = (byte)(y % 255); // green
components[2] = (byte)(x * y % 255); // red
components[3] = 0; // unused
int pixelValue = BitConverter.ToInt32(components, 0);
// Set the value for the
b.Pixels[y * imageWidth + x] = pixelValue;
}
}
b.Invalidate();
inputImage.Source = b;
Thanks for the help Riccardo