6
Q
調整圖像
A
回答
20
我已經找到了一個很好的和簡單的例子here
C#和GDI +有一個簡單的方法來控制要繪製的顏色。 它基本上是一個ColorMatrix。這是一個5×5矩陣,如果已設置,則應用於每種顏色的 。調整亮度只是執行 翻譯上的顏色數據,以及對比度上 顏色進行規模。伽瑪是一個完全不同的形式變換,但它包含在其中接受嘉洛斯ImageAttributes 。
Bitmap originalImage;
Bitmap adjustedImage;
float brightness = 1.0f; // no change in brightness
float contrast = 2.0f; // twice the contrast
float 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 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,originalImage.Width,originalImage.Height,
GraphicsUnit.Pixel, imageAttributes);
相關問題
- 1. 調整圖像
- 2. Bitmap.decodeResource調整圖像
- 3. PHP調整圖像
- 4. uitableviewcell調整圖像
- 5. 調整圖像大小調整
- 6. 調整圖像大小時調整
- 7. Codeigniter圖像調整大小隻調整一個圖像
- 8. 通過javascript調整圖像大小或調整圖像尺寸
- 9. 調整圖像上的圖像點擊
- 10. 在UIButton上調整圖像
- 11. Base64圖像調整器nodejs
- 12. 圖像未調整大小
- 13. 調整jpeg圖像大小?
- 14. codeigniter圖像調整大小
- 15. JAI圖像調整瓶頸
- 16. 調整圖像的亮度
- 17. Phalcon圖像調整大小
- 18. TitleAreaDialog - 調整標題圖像
- 19. JavaFx圖像調整大小
- 20. ckfinder圖像調整大小
- 21. Carrierwave調整現有圖像
- 22. 圖像調整大小Codeigniter
- 23. 調整圖像大小。 。 。 。
- 24. 調整圖像的來源
- 25. Xamarin Mac - 調整圖像
- 26. 在css中調整圖像
- 27. 圖像調整大小Java
- 28. 調整圖像大小
- 29. 調整圖像大小
- 30. 圖像調整時旋轉