public void RenderRaster(Graphics g, Bitmap bitmap, RasterStyle style, BoundingRectangle viewBox, BoundingRectangle bitmapBounds, double scaleFactor) { ICoordinate minPoint = bitmapBounds.Min; ICoordinate maxPoint = bitmapBounds.Max; if (viewBox.Intersects(bitmapBounds)) { Point minP = new Point((int)((minPoint.X - viewBox.MinX) * scaleFactor), (int)((viewBox.MaxY - minPoint.Y) * scaleFactor)); Point maxP = new Point((int)((maxPoint.X - viewBox.MinX) * scaleFactor), (int)((viewBox.MaxY - maxPoint.Y) * scaleFactor)); g.InterpolationMode = style.InterpolationMode; Rectangle r = new Rectangle(minP.X, maxP.Y, maxP.X - minP.X, minP.Y - maxP.Y); using (ImageAttributes imageAttributes = new ImageAttributes()) { imageAttributes.SetColorMatrix(style.ColorAdjustmentMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); g.DrawImage(bitmap, r, 0, 0, bitmap.Width, bitmap.Height, GraphicsUnit.Pixel, imageAttributes); } } }
/// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns>A new object that is a copy of this instance</returns> public object Clone() { ColorMatrix cm = this.ColorAdjustmentMatrix; RasterStyle rs = new RasterStyle() { InterpolationMode = this.InterpolationMode, ColorAdjustmentMatrix = new ColorMatrix( new float[][] { new float[] { cm.Matrix00, cm.Matrix01, cm.Matrix02, cm.Matrix03, cm.Matrix04 }, new float[] { cm.Matrix10, cm.Matrix11, cm.Matrix12, cm.Matrix13, cm.Matrix14 }, new float[] { cm.Matrix20, cm.Matrix21, cm.Matrix22, cm.Matrix23, cm.Matrix24 }, new float[] { cm.Matrix30, cm.Matrix31, cm.Matrix32, cm.Matrix33, cm.Matrix34 }, new float[] { cm.Matrix40, cm.Matrix41, cm.Matrix42, cm.Matrix43, cm.Matrix44 } }) }; return(rs); }
/// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns>A new object that is a copy of this instance</returns> public object Clone() { ColorMatrix cm = this.ColorAdjustmentMatrix; RasterStyle rs = new RasterStyle() { InterpolationMode = this.InterpolationMode, ColorAdjustmentMatrix = new ColorMatrix( new float[][] { new float[] {cm.Matrix00, cm.Matrix01, cm.Matrix02, cm.Matrix03, cm.Matrix04}, new float[] {cm.Matrix10, cm.Matrix11, cm.Matrix12, cm.Matrix13, cm.Matrix14}, new float[] {cm.Matrix20, cm.Matrix21, cm.Matrix22, cm.Matrix23, cm.Matrix24}, new float[] {cm.Matrix30, cm.Matrix31, cm.Matrix32, cm.Matrix33, cm.Matrix34}, new float[] {cm.Matrix40, cm.Matrix41, cm.Matrix42, cm.Matrix43, cm.Matrix44}}) }; return rs; }