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 ...@@ -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) public void DrawImageUnscaled(Image image, Point location)
{ {
...@@ -94,7 +100,6 @@ namespace SVGViewer ...@@ -94,7 +100,6 @@ namespace SVGViewer
} }
public SmoothingMode SmoothingMode public SmoothingMode SmoothingMode
{ {
get { return SmoothingMode.Default; } get { return SmoothingMode.Default; }
......
...@@ -209,7 +209,10 @@ namespace Svg ...@@ -209,7 +209,10 @@ namespace Svg
if (bmp != null) if (bmp != null)
{ {
if(Opacity==1F)
renderer.DrawImage(bmp, destRect, srcRect, GraphicsUnit.Pixel); renderer.DrawImage(bmp, destRect, srcRect, GraphicsUnit.Pixel);
else
renderer.DrawImage(bmp, destRect, srcRect, GraphicsUnit.Pixel, Opacity);
bmp.Dispose(); bmp.Dispose();
} }
else if (svg != null) else if (svg != null)
......
...@@ -22,5 +22,6 @@ namespace Svg ...@@ -22,5 +22,6 @@ namespace Svg
SmoothingMode SmoothingMode { get; set; } SmoothingMode SmoothingMode { get; set; }
Matrix Transform { get; set; } Matrix Transform { get; set; }
void TranslateTransform(float dx, float dy, MatrixOrder order = MatrixOrder.Append); 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; ...@@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text; using System.Drawing.Text;
namespace Svg namespace Svg
...@@ -46,6 +47,21 @@ namespace Svg ...@@ -46,6 +47,21 @@ namespace Svg
{ {
_innerGraphics.DrawImage(image, destRect, srcRect, graphicsUnit); _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) public void DrawImageUnscaled(Image image, Point location)
{ {
this._innerGraphics.DrawImageUnscaled(image, 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