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. 图像调整时旋转