在 .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);

8 個回應:

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

Unknown 提到...

شركة تسليك مجاري بالرياض
افضل شركة تنظيف منازل بالرياض
اسعار غسيل السجاد بالرياض
فك و تركيب باركيه بالرياض

Cara menyembuhkan tbc 提到...

given article is very helpful and very useful for my admin, and pardon me permission to share articles here hopefully helped :

Obat hipertiroid
Obat penurun kolesterol jahat
Cara menyembuhkan penyakit asam urat
Obat infeksi saluran kencing wanita
Obat tradisional penyakit gula
Cara mengatasi otot jantung lemah
Cara menyembuhkan kanker pankreas

Rose Blackpink 提到...

This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It is the old what goes around comes around routine

risa herbal
penyebab sakit pinggang
obat penyakit mata glaukoma
obat gagal ginjal
obat penebalan dinding rahim
obat penghancur kanker
obat varikokel

Frank 提到...

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

張貼留言