Fehler bei 16-BPP-Gray-Image

  • WPF

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von RodFromGermany.

    Fehler bei 16-BPP-Gray-Image

    Moin Leute,
    ich habe ein Bild, das ich als Gray16-Bild speichern möchte:

    C#-Quellcode

    1. using System.Windows;
    2. using System.Windows.Media;
    3. using System.Windows.Media.Imaging;

    C#-Quellcode

    1. PictureTiff pt = new PictureTiff();
    2. PictureTiff.PictureInfo pi = new PictureBase.PictureInfo
    3. {
    4. Orientation = 1,
    5. SourceWidth = this.Width,
    6. Width = this.Width,
    7. Height = this.Height,
    8. ShiftValue = this.ShiftValue
    9. };
    10. pi.PictureType = PictureBase.EPictureType.Grey16;
    11. pi.SourceType = PictureBase.ESourceType.Grey16;
    12. pi.Picture16 = this.ImageMemory;
    13. pt.WritePicture(path, pi);
    Funktioniert so weit.
    Gelesen wird es mit diesem Code:

    C#-Quellcode

    1. BitmapImage bmp = new BitmapImage(new Uri(fileName, UriKind.Absolute));

    Problem: Unter .NET wird das Format nicht erkannt:
    .NET:

    Explorer:

    IrfanView:

    Weiß jemand von Euch, wie man unter .NET das richtige Format auslesen kann?
    Falls Du diesen Code kopierst, achte auf die C&P-Bremse.
    Jede einzelne Zeile Deines Programms, die Du nicht explizit getestet hast, ist falsch :!:
    Ein guter .NET-Snippetkonverter (der ist verfügbar).
    Programmierfragen über PN / Konversation werden ignoriert!
    Habe auch mal probiert...

    Also wenn ich es so wie du mache, bekomme ich bei jedem Bild Bgr32. Nutze ich einen BitmapDecoder passt es eher.

    C#-Quellcode

    1. using (FileStream fs = new FileStream(fileName, FileMode.Open))
    2. {
    3. BitmapDecoder decoder = BitmapDecoder.Create(fs, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None);
    4. MessageBox.Show(decoder.Frames[0].Format.ToString());
    5. MessageBox.Show(decoder.Frames[0].Format.BitsPerPixel.ToString());
    6. MessageBox.Show(decoder.Frames[0].Decoder.CodecInfo.FriendlyName);
    7. }

    And i think to myself... what a wonderfuL World!

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Eddy“ ()