0

I want to develop a Steganography software in WPF, so I need direct access to pixels, I am trying to convert a Bitmap to an array and edit it, the problem is I can only recreate it by BitmapSource (am I right?) and I can't recreate it correctly. I get a Black and White Image instead.

public static void Conceal(BitmapImage CoverPhotoBitmap, BitmapImage HiddenPhotoBitmap, ref BitmapSource ResultPhotoBitmapSource)
{
    int stride = CoverPhotoBitmap.PixelWidth * 4;
    int size = CoverPhotoBitmap.PixelHeight * stride;
    byte[] CoverPhotoPixels = new byte[size];
    CoverPhotoBitmap.CopyPixels(CoverPhotoPixels, stride, 0);

    byte[] HiddenPhotoPixels = new byte[size];
    HiddenPhotoBitmap.CopyPixels(HiddenPhotoPixels, stride, 0);
    ResultPhotoBitmapSource = BitmapSource.Create(CoverPhotoBitmap.PixelWidth, CoverPhotoBitmap.PixelHeight, 96, 96, PixelFormats.Rgb32, null, HiddenPhotoPixels, stride);
}

1 Answers1

0

You may convert your resulting BitmapSource to a BitmapImage. Check the answer to this question: BitmapSource to BitmapImage.

Not marking as duplicate since it's not the same question, although the answer applies.

Community
  • 1
  • 1
Jcl
  • 27,696
  • 5
  • 61
  • 92
  • I read that page before, I don't need to convert Bitmap to BitmapSource directly, in fact I need my "array" to be converted to a BitmapSource (or a Bitmap if it is possible). I want to be able to use it as ResultPhoto.Source in visual mode (xaml) – MostafaMohammadi Jan 08 '15 at 10:29
  • I thought by reading your question that your problem was converting the `BitmapSource` to a `BitmapImage`... if your problem is converting back from the array, check this: http://stackoverflow.com/questions/14337071/convert-array-of-bytes-to-bitmapimage – Jcl Jan 08 '15 at 10:30