hej.
Mam pytanie gdzie popełniam błąd w kodzie.
BitmapSource Zapisuje mi do PNG ale całkowicie przezroczysty, jeżeli użyję jakiego programu do robienia screanschotów.
Kod działa poprawnie jeżeli użyję klawisza "Printscrean"
public byte[] getPNGFromImageControl(BitmapSource imageC)
{
Bitmap bmp = new Bitmap(
imageC.PixelWidth,
imageC.PixelHeight,
PixelFormat.Format32bppPArgb);
BitmapData data = bmp.LockBits(
new Rectangle(System.Drawing.Point.Empty, bmp.Size),
ImageLockMode.WriteOnly,
PixelFormat.Format32bppPArgb);
imageC.CopyPixels(
Int32Rect.Empty,
data.Scan0,
data.Height * data.Stride,
data.Stride);
bmp.UnlockBits(data);
MemoryStream memory = new MemoryStream();
bmp.Save(memory, ImageFormat.Png);
byte[] bytes = memory.ToArray();
return memory.GetBuffer();
}
string outputFileName = "./obrazki/obrazek.png";
using (FileStream fs = new FileStream(outputFileName, FileMode.Create, FileAccess.ReadWrite))
{
thumbBMP.Save(memory, ImageFormat.Png);
byte[] bytes = memory.ToArray();
fs.Write(bytes, 0, bytes.Length);
}
PS. Internet przeorałem od deski do deski