在 .Net 使用 GDI+ 調整圖片亮度

也就是 RGB 一起調啦!

原始出處


Bitmap origanalImage;
Bitmap adjustedImage;
double brightness = 1.0f; // no change in brightness
double constrast = 2.0f; // twice the contrast
double gamma = 1.0f; // no change in gamma

float adjustedBrightness = brightness - 1.0f;
// create matrix that will brighten and contrast the image
float[][] ptsArray ={
new float[] {contrast, 0, 0, 0, 0}, // scale red
new float[] {0, contrast, 0, 0, 0}, // scale green
new float[] {0, 0, contrast, 0, 0}, // scale blue
new float[] {0, 0, 0, 1.0f, 0}, // don't scale alpha
new float[] {adjustedBrightness, adjustedBrightness, adjustedBrightness, 0, 1}};

imageAttributes = new ImageAttributes();
imageAttributes.ClearColorMatrix();
imageAttributes.SetColorMatrix(new ColorMatrix(ptsArray), ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
imageAttributes.SetGamma(gamma, ColorAdjustType.Bitmap);
Graphics g = Graphics.FromImage(adjustedImage);
g.DrawImage(originalImage, new Rectangle(0,0,adjustedImage.Width,adjustedImage.Height)
,0,0,bitImage.Width,bitImage.Height,
GraphicsUnit.Pixel, imageAttributes);

5 個回應:

Unknown 提到...

您好林先生, 不知該如何與您聯絡上呢?

我們對您的軟體功力很有興趣是否可以跟您談談?

Sean Lin 提到...

Re: Jeffery <2948470297290767268>

歡迎呀!
我的 Email 是 sean.tw小老鼠gmail.com

chenlina 提到...

oakley sunglasses
louis vuitton belt
christian louboutin heels
tory burch outlet
nike air max
louis vuitton
toms shoes
louis vuitton
cheap nhl jerseys
nike nfl jerseys
chenlina20170109

Unknown 提到...

coach outlet
tiffany outlet
canada goose outlet
michael kors outlet
ed hardy
birkenstocks
air jordan retro
yeezy boost
longchamp uk
cheap oakley sunglasses
20170224caiyan

Frank 提到...

thank for sharing a great article. Buy Essay Online this is helpful article.

張貼留言