도전2022

WPF를 이용해서 알파가 있는 이미지를 넣을려고 했는데, 알파가 적용안되고 있으면 본문

작업/work2012

WPF를 이용해서 알파가 있는 이미지를 넣을려고 했는데, 알파가 적용안되고 있으면

hotdigi 2012. 3. 29. 17:14

간만에 WPF를 사용하고 있는데, 

분명히 알파가 있는 PNG 파일인데, 이미지 표현을 하면 알파가 적용되지 않고, 디스플레이 된다. ㅠㅠ


한 1시간은 검색했다. 

혹시, ImageBrush 가 PNG를 지원하지 않는지, 

혹시, 알파를 사용한다고 지정해야 하는지 등등, 

엄청 찾아보았다. 


다음과 같은 글도 있다. 

WPF - ImageBrush with PNG, not respecting alpha-channel

http://stackoverflow.com/questions/1531792/wpf-imagebrush-with-png-not-respecting-alpha-channel

I want to use an ImageBrush to use in the Rectangle.Fill. The file is a .PNG. It comes out looking like it is sitting on a little gray pad. The ImageBrush is returned from a converter with something like this:

        BitmapImage image = new BitmapImage(new Uri(fileName));

        ImageBrush imageBrush = new ImageBrush();

        imageBrush.ImageSource = image;


하지만, 이유는 이미지를 불러와서 저장하면서 BMP로 저장해서 투명이 안된 것이 문제였다. ㅠ.ㅠ

img.Save(imgStream, System.Drawing.Imaging.ImageFormat.Bmp);


img.Save(imgStream, System.Drawing.Imaging.ImageFormat.Png);


혹시 나처럼 고생하고 헛고생을 하고 있는 분이 없기를 바라면서 글을 올린다. 



'작업 > work2012' 카테고리의 다른 글

Motherboard E35M1-I DELUXE  (0) 2012.04.02
터치 스크린  (0) 2012.03.29
디자인 초안  (0) 2012.03.27
스마트폰 앱들  (0) 2012.03.27
FindWindow Test  (0) 2012.03.23