c# - Change an image dpi without changing it's pixal format -
every time try change image's dpi, pixel format (color scheme - rgb, cmyk , such...) seems change. time did succeed in saving pixel format, dpi, on debug mode, seems change, after process complete, changed it's original settings.
the code tried followed:
using (var ms = new memorystream()) { using (var bmpinput = image.fromfile(path) bitmap) { using (var bmpoutput = (bitmap)bmpinput.clone()) { foreach (var id in bmpinput.propertyidlist) bmpoutput.setpropertyitem(bmpinput.getpropertyitem(id)); if (doresize) bmpoutput.setresolution(dpi, dpi); bmpoutput.save(ms, bmpinput.rawformat); return ms.toarray(); } } }
application.doevents();
try before saving image in code.
Comments
Post a Comment