c# - Images without being compressed to bitmap? -
i have program uses pngs , when put them in resources downgraded bitmap supports 24 bit color. there way can keep image quality being screwed up?
private void form1_load_1(object sender, eventargs e) { image nsmbwimg = (image)properties.resources.nsmbwimg; image okamiimg = (image)properties.resources.okamiimg; game nsmbw = new game("new super mario bros. wii", "nintendo", "nintendo", "november 15,2009", "wii", "2d platformer", "4", "mario leaps new adventure! scramble through courses 4 players @ same time! run, stomp, , fly through 8 worlds packed enemies , surprises.", nsmbwimg); game ookami = new game("Ōkami", "clover studio", "capcom", "ps2: september 19, 2006 wii: april 15, 2008", "ps2/wii", "action-adventure", "1", "play wolf incarnation of japanese sun goddess amaterasu , channel divine powers through mighty celestial paintbrush restore beauty , order bleak world overrun evil.", okamiimg); games.add(nsmbw); games.add(ookami); } i want make sure image quality doesn't change, possibly host image on website? or possibly include in folder without putting resources?
add png file project ( right click on project solution explorer -> add existing item ), once added in file properties, set build action : embedded resource.

to load image
using(stream stream = assembly.getexecutingassembly().getmanifestresourcestream("<root namespace assembly>.<folder name>.<image file name>")) { image = image.fromstream(stream); } another example
using ( stream stream = assembly.getexecutingassembly() .getmanifestresourcestream("windowsformsapplication1.testimage.png")) { picturebox1.image = image.fromstream(stream); }
Comments
Post a Comment