asp.net - Why does this C# image handler change the color of my image? -


i have below image handler method resize , save image, changes image's color enough notice. passing in 100 quality value. might losing mind swear on occasion doesnt affect colors. last 10 test ran did.

public string save(bitmap image, int maxwidth, int maxheight, int quality, string pathwithname, out int iwidth, out int iheight)     {          // image's original width , height         int originalwidth = image.width;         int originalheight = image.height;         int newwidth = 0;         int newheight = 0;          if (originalwidth < maxwidth && originalheight < maxheight)         {             newwidth = originalwidth;             newheight = originalheight;          }         else         {             // preserve aspect ratio             float ratiox = (float)maxwidth / (float)originalwidth;             float ratioy = (float)maxheight / (float)originalheight;             float ratio = math.min(ratiox, ratioy);              // new width , height based on aspect ratio             newwidth = (int)(originalwidth * ratio);             newheight = (int)(originalheight * ratio);         }         // convert other formats (including cmyk) rgb.         bitmap newimage = new bitmap(newwidth, newheight, pixelformat.format24bpprgb);          // draws image in specified size quality mode set highquality         using (graphics graphics = graphics.fromimage(newimage))         {             graphics.compositingquality = compositingquality.highquality;             graphics.interpolationmode = interpolationmode.highqualitybicubic;             graphics.smoothingmode = smoothingmode.highquality;             graphics.drawimage(image, 0, 0, newwidth, newheight);         }          // imagecodecinfo object represents jpeg codec.         imagecodecinfo imagecodecinfo = this.getencoderinfo(imageformat.jpeg);          // create encoder object quality parameter.         encoder encoder = encoder.quality;          // create encoderparameters object.          encoderparameters encoderparameters = new encoderparameters(1);          // save image jpeg file quality level.         encoderparameter encoderparameter = new encoderparameter(encoder, quality);         encoderparameters.param[0] = encoderparameter;         newimage.save(pathwithname, imagecodecinfo, encoderparameters);          iwidth = newwidth;         iheight = newheight;         return pathwithname;     } 


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -