c# - How to fill transperent pixels of tiff file and keep geo information -
i want fill transperent pixels of tif file contain geodetic information (map) black color. when open file photoshop example dont see transperent pixels, when open geodetic system "arcmap" example can notice of pixels transperent. thats have try do:
private void button1_click(object sender,eventargs e) { bitmap bmp=null; using(image img =image.fromfile(@"filelocation.tif") { bmp=new bitmap(img); for(int y=0;y<bmp.height;y++) { for(int x=0; x<bmp.width;x++) { if(bmp.getpixel(x,y).a!=255) { bmp.setpixel(x,y,color.black); } } } } } bmp.save(@"new file location "); results :
1)the number of pixel same size of image smaller,why?
2)i have tried condition ( getpixel(x,y).a!=255) on bmp file , detected transperent pixels , when execute method on tif file doesn't detect transperent pixels , why ?
3)it doesnt matter if execute method on 8\24 bit image convert 24bit compressed image ,why thats happen ?
4)when execute method geodetic information disapper ,therefore map not longer map file without geodetic information ... can excute method fill transpert pixel out generate new file ?(in order keep geodetic information)
5)although save file in tif format , when on tif data ( tool called displayheader represent information file ) seems converted format png file ..., why that's happen ? thanks!
private void button1_click(object sender,eventargs e) { bitmap bmp=null; using(image img =image.fromfile(@"filelocation.tif") { bmp=new bitmap(img); bmp.maketransparent(); for(int y=0;y<bmp.height;y++) { for(int x=0; x<bmp.width;x++) { if(bmp.getpixel(x,y).a!=255) { bmp.setpixel(x,y,color.black); } } } } } bmp.save(@"new file location "); please add bmp.maketransparent() function make transparent bitmap image
Comments
Post a Comment