Microsoft Developer Network > 포럼 홈 > Windows Presentation Foundation (WPF) > How to decode tiff file and preserve opacity?
질문하기질문하기
 

답변됨How to decode tiff file and preserve opacity?

  • 2009년 7월 3일 금요일 오후 8:37silverweb 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    By default, standard TiffBitmapDecoder decodes to flatten image with white background. All transparency converts to white. But if I save in Photoshop file in tiff format, with not recently used option, "Save Transparency", TiffBitmapDecoder converts fine and preserve opacity.

    I need solution, how I can import all tiff files and preserve opacity, or how I can read alpha chanel or mask information from file to have ability add Opacity.Mask to Image?

     

     

     

답변

  • 2009년 7월 6일 월요일 오후 11:31Jordan Parker - MSFT 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

    Eric from the WIC team says this:

    "The problem is that, when Photoshop saves a TIFF file, it handles alpha by using custom metadata which stores Photoshop’s proprietary layer information. If “save layers” is turned off, even Photoshop won’t recognize that the saved image has alpha.

    The most standard way to support alpha in a TIFF file is to use an extra sample representing the alpha channel. By default, Photoshop doesn’t write this sample, so WIC has no good way of detecting that the image includes alpha. If the “Save transparency” option is checked in Photoshop, it will write the alpha channel, in which case WIC should recognize and display the alpha properly.

    Given that Adobe’s default way of saving alpha is proprietary and based on the Photoshop layer system, most applications won’t detect the TIFF’s alpha unless the “Save transparency” option is checked (I confirmed with IrfanView, Picassa didn’t seem to support TIFF transparency)."

    You need to use "save transparency."

    • 답변으로 표시됨silverweb 2009년 7월 7일 화요일 오후 8:28
    •  

모든 응답

  • 2009년 7월 4일 토요일 오후 8:58Mark SalsberyMVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Are you using the "PreservePixelFormat" create option on the TiffBitmapDecoder?

    Mark Salsbery Microsoft MVP - Visual C++
  • 2009년 7월 5일 일요일 오전 11:41silverweb 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     코드 있음
    Are you using the "PreservePixelFormat" create option on the TiffBitmapDecoder?

    Mark Salsbery Microsoft MVP - Visual C++

    Yes, but same result for BitmapCreateOptions.None

    Stream imageStreamSource = new FileStream("C:/Users/*/*.tif", FileMode.Open, FileAccess.Read, FileShare.Read);
    TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
                
    BitmapSource bitmapSource = decoder.Frames[0];
    testImage.Source = bitmapSource;
    
  • 2009년 7월 6일 월요일 오후 11:31Jordan Parker - MSFT 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

    Eric from the WIC team says this:

    "The problem is that, when Photoshop saves a TIFF file, it handles alpha by using custom metadata which stores Photoshop’s proprietary layer information. If “save layers” is turned off, even Photoshop won’t recognize that the saved image has alpha.

    The most standard way to support alpha in a TIFF file is to use an extra sample representing the alpha channel. By default, Photoshop doesn’t write this sample, so WIC has no good way of detecting that the image includes alpha. If the “Save transparency” option is checked in Photoshop, it will write the alpha channel, in which case WIC should recognize and display the alpha properly.

    Given that Adobe’s default way of saving alpha is proprietary and based on the Photoshop layer system, most applications won’t detect the TIFF’s alpha unless the “Save transparency” option is checked (I confirmed with IrfanView, Picassa didn’t seem to support TIFF transparency)."

    You need to use "save transparency."

    • 답변으로 표시됨silverweb 2009년 7월 7일 화요일 오후 8:28
    •  
  • 2009년 7월 7일 화요일 오후 8:45silverweb 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    Thanks a lot for reply, it's helpful information for me.
    tnx