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. uitableviewcell调整图像
- 3. PHP调整图像
- 4. 调整图像大小时调整
- 5. 调整图像大小调整
- 6. AS3 - 调整图像颜色
- 7. 调整图像大小
- 8. CSS中的图像调整
- 9. Drupal - 图像调整大小
- 10. 图像的大小调整
- 11. 动态图像调整
- 12. 调整图像大小5
- 13. Laravel 5.2 - Intervation图像调整
- 14. php调整大小图像
- 15. CSS图像位置调整
- 16. 调整图像大小
- 17. Opencart - 图像调整大小
- 18. 图像调整脚本
- 19. JavaME调整图像大小
- 20. 调整图像使用PHP
- 21. PHP:调整图像大小
- 22. Javascript图像调整大小
- 23. 调整图像使用jQuery
- 24. 花式框调整图像
- 25. 图像调整大小捏
- 26. 图像调整时旋转
- 27. 调整图像大小 - Symfony
- 28. 图像不自动调整
- 29. TCPDF图像调整大小
- 30. imageWithContentsOfFile调整图像大小