Commit 0453531d authored by Vitaly Derbin's avatar Vitaly Derbin Committed by mrbean-bremen
Browse files

347

# image opacity fix
parent e72d713a
......@@ -37,6 +37,12 @@ namespace SVGViewer
{
}
public void DrawImage(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit graphicsUnit, float opacity)
{
}
public void DrawImageUnscaled(Image image, Point location)
{
......@@ -91,8 +97,7 @@ namespace SVGViewer
public void TranslateTransform(float dx, float dy, MatrixOrder order = MatrixOrder.Append)
{
_transform.Translate(dx, dy, order);
}
}
public SmoothingMode SmoothingMode
......
......@@ -209,7 +209,10 @@ namespace Svg
if (bmp != null)
{
renderer.DrawImage(bmp, destRect, srcRect, GraphicsUnit.Pixel);
if(Opacity==1F)
renderer.DrawImage(bmp, destRect, srcRect, GraphicsUnit.Pixel);
else
renderer.DrawImage(bmp, destRect, srcRect, GraphicsUnit.Pixel, Opacity);
bmp.Dispose();
}
else if (svg != null)
......
......@@ -22,5 +22,6 @@ namespace Svg
SmoothingMode SmoothingMode { get; set; }
Matrix Transform { get; set; }
void TranslateTransform(float dx, float dy, MatrixOrder order = MatrixOrder.Append);
void DrawImage(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit graphicsUnit, float opacity);
}
}
......@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
namespace Svg
......@@ -46,6 +47,21 @@ namespace Svg
{
_innerGraphics.DrawImage(image, destRect, srcRect, graphicsUnit);
}
public void DrawImage(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit graphicsUnit, float opacity)
{
var matrix = new ColorMatrix {Matrix33 = opacity};
var attributes = new ImageAttributes();
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
var points = new[]
{
destRect.Location,
new PointF(destRect.X + destRect.Width, destRect.Y),
new PointF(destRect.X, destRect.Y + destRect.Height)
};
_innerGraphics.DrawImage(image, points, srcRect, graphicsUnit, attributes);
}
public void DrawImageUnscaled(Image image, Point location)
{
this._innerGraphics.DrawImageUnscaled(image, location);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment