C# Copying PNG with transparency to clipboard -
i taking existing png image file has transparent portion, adding text on top (using graphics.drawstring()) before saving image disk.
i save image clipboard. however, when seek paste resulting image ms paint, transparent regions lite gray. saved file retains transparency correctly.
this have:
//reads file system.drawing.image filestream fs = new filestream(filelocation, filemode.open, fileaccess.read); image image = image.fromstream(fs); fs.close(); //add text image via system.drawing.graphics bitmap mybitmap = new bitmap(image); graphics g = graphics.fromimage(mybitmap); g.drawstring(texttoadd, new font("tahoma", 14), system.drawing.brushes.black, new pointf(0, 0)); //save modified image disk (transparency works) mybitmap.save(filelocation, system.drawing.imaging.imageformat.png); //copy clipboard (transparent areas gray) system.windows.forms.clipboard.setimage(mybitmap);
answering own question.
what have not work in current environment (windows 7) because win7 not back upwards transparency in clipboard. work in windows 8 environment.
c# png clipboard
No comments:
Post a Comment