//--------------------------------------------------------------------------------------------------------- /// <summary> /// Изменение режима заполнения кисти. /// Метод автоматически вызывается после установки соответствующего свойства /// </summary> //--------------------------------------------------------------------------------------------------------- protected virtual void RaiseExtendModeChanged() { #if USE_WINDOWS System.Windows.Media.ImageBrush image_brush = mWindowsBrush as System.Windows.Media.ImageBrush; image_brush.TileMode = GetTileMode(); // 2) Информируем об изменении NotifyPropertyChanged(PropertyArgsWindowsBrush); #endif #if USE_GDI if (mDrawingBrush != null) { System.Drawing.TextureBrush gdi_image_brush = mDrawingBrush as System.Drawing.TextureBrush; gdi_image_brush.WrapMode = (System.Drawing.Drawing2D.WrapMode)GetTileMode(); } #endif #if USE_SHARPDX if (mD2DBrush != null) { SharpDX.Direct2D1.BitmapBrush d2d_image_brush = mD2DBrush as SharpDX.Direct2D1.BitmapBrush; d2d_image_brush.ExtendModeX = (SharpDX.Direct2D1.ExtendMode)mExtendModeX; d2d_image_brush.ExtendModeY = (SharpDX.Direct2D1.ExtendMode)mExtendModeY; } #endif }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { // if (this.Type != ButtonType.None) // { // if (this.Parent != null) // e.Graphics.DrawRectangle(new System.Drawing.Pen(this.Parent.BackColor),this.Location.X,this.Location.Y,this.Width,this.Height); // e.Graphics.DrawImage(this.Image,this.Location.X,this.Location.Y,this.Width,this.Height); // return; // } base.OnPaint(e); if (m_enumGradientSource != Button.GradientSource.None) { System.Drawing.Graphics g = e.Graphics; System.Drawing.Rectangle clientRect = this.ClientRectangle; clientRect.Inflate(-1, -1); System.Drawing.Brush backgroundBrush; switch (m_enumGradientSource) { case Button.GradientSource.Color: backgroundBrush = new System.Drawing.Drawing2D.LinearGradientBrush(new System.Drawing.Rectangle(clientRect.X, clientRect.Y, clientRect.Width, clientRect.Height), this.m_clrGradientStart, this.m_clrGradientEnd, this.m_2dMode); g.FillRectangle(backgroundBrush, clientRect); g.DrawString(this.Text, this.Font, new System.Drawing.SolidBrush(this.ForeColor), clientRect, m_s_strfFormat); break; case Button.GradientSource.Image: if (this.BackgroundImage != null) { backgroundBrush = new System.Drawing.TextureBrush(this.BackgroundImage); g.FillRectangle(backgroundBrush, clientRect); g.DrawString(this.Text, this.Font, new System.Drawing.SolidBrush(this.ForeColor), clientRect, m_s_strfFormat); } break; } } }
//--------------------------------------------------------------------------------------------------------- /// <summary> /// Изменение имени ресурса кисти. /// Метод автоматически вызывается после установки соответствующего свойства /// </summary> //--------------------------------------------------------------------------------------------------------- protected virtual void RaiseResourceNameChanged() { #if USE_WINDOWS System.Windows.Media.ImageBrush image_brush = mWindowsBrush as System.Windows.Media.ImageBrush; image_brush.ImageSource = XWindowsLoaderBitmap.LoadBitmapFromResource(Properties.Resources.ResourceManager, mResourceName); image_brush.Viewport = new System.Windows.Rect(0, 0, image_brush.ImageSource.Width, image_brush.ImageSource.Height); // 2) Информируем об изменении NotifyPropertyChanged(PropertyArgsWindowsBrush); #endif #if USE_GDI if (mDrawingBrush != null) { mDrawingBrush.Dispose(); } Object image = Properties.Resources.ResourceManager.GetObject(mResourceName); System.Drawing.Bitmap source = (System.Drawing.Bitmap)image; mDrawingBrush = new System.Drawing.TextureBrush(source, (System.Drawing.Drawing2D.WrapMode)GetTileMode()); #endif #if USE_SHARPDX if (mD2DBrush != null) { SharpDX.Direct2D1.BitmapBrush d2d_image_brush = mD2DBrush as SharpDX.Direct2D1.BitmapBrush; d2d_image_brush.Bitmap = XDirect2DManager.LoadFromResource(mResourceName); } #endif }
} // End Function GetHatchImage public static System.Drawing.Brush GetBrush(int iLegendPattern, System.Drawing.Color colFC, System.Drawing.Color colHB, System.Drawing.Color colHL) { if (iLegendPattern == 12) // Normal, SolidBrush { return(new System.Drawing.SolidBrush(colFC)); } else if (iLegendPattern == 43) // MB: Leerstand, HatchBrush - HatchStyle.DarkUpwardDiagonal { return(new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.DarkUpwardDiagonal, System.Drawing.Color.Black, System.Drawing.Color.White)); } else if (iLegendPattern == 0) // 0 -- >40 Zeilen / >40 lignes, keine { return(null); // Console.WriteLine("40 Zeilen / >40 lignes"); } //else // [9: kein Mietobjekt,35: MB Mieter ], TextureBrush //Image image = Image.FromFile(@"D:\stefan.steiger\documents\visual studio 2010\Projects\DrawLegends\DrawLegends\hatches\hatch" + iLegendPattern + ".png"); System.Drawing.TextureBrush tb = null; using (System.Drawing.Image image = GetHatchImage(iLegendPattern, colFC)) { tb = new System.Drawing.TextureBrush(image, System.Drawing.Drawing2D.WrapMode.Tile); } // End Using Image image // tb.TranslateTransform(x, y); return(tb); } // End Function GetBrush
//--------------------------------------------------------------------------------------------------------- /// <summary> /// Обновление ресурса System.Drawing /// </summary> //--------------------------------------------------------------------------------------------------------- public override void UpdateDrawingResource() { if (mDrawingBrush != null) { mDrawingBrush.Dispose(); } Object image = Properties.Resources.ResourceManager.GetObject(mResourceName); System.Drawing.Bitmap source = (System.Drawing.Bitmap)image; mDrawingBrush = new System.Drawing.TextureBrush(source, (System.Drawing.Drawing2D.WrapMode)GetTileMode()); }
public System.Drawing.Image RoundCorners(BitmapImage StartImage, int CornerRadius, System.Drawing.Color BackgroundColor) { System.Drawing.Image img = System.Drawing.Image.FromFile(StartImage.UriSource.LocalPath); CornerRadius *= 2; System.Drawing.Bitmap RoundedImage = new System.Drawing.Bitmap(img.Width, img.Height); using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(RoundedImage)) { g.Clear(BackgroundColor); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; System.Drawing.Brush brush = new System.Drawing.TextureBrush(img); System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath(); gp.AddArc(0, 0, CornerRadius, CornerRadius, 180, 90); gp.AddArc(0 + RoundedImage.Width - CornerRadius, 0, CornerRadius, CornerRadius, 270, 90); gp.AddArc(0 + RoundedImage.Width - CornerRadius, 0 + RoundedImage.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90); gp.AddArc(0, 0 + RoundedImage.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90); g.FillPath(brush, gp); return(RoundedImage); } }
internal static void SetBrushMatrix(System.Drawing.Brush brush, System.Drawing.Drawing2D.Matrix matrix) { if (brush == null) { throw new System.ArgumentNullException("brush"); } if (brush.GetType() == typeof(System.Drawing.TextureBrush)) { System.Drawing.TextureBrush textureBrush = (System.Drawing.TextureBrush)brush; textureBrush.Transform = matrix; } else if (brush.GetType() == typeof(System.Drawing.Drawing2D.LinearGradientBrush)) { System.Drawing.Drawing2D.LinearGradientBrush linearGradientBrush = (System.Drawing.Drawing2D.LinearGradientBrush)brush; linearGradientBrush.Transform = matrix; } else if (brush.GetType() == typeof(System.Drawing.Drawing2D.PathGradientBrush)) { System.Drawing.Drawing2D.PathGradientBrush pathGradientBrush = (System.Drawing.Drawing2D.PathGradientBrush)brush; pathGradientBrush.Transform = matrix; } }
/// <summary> /// Initializes a new <see cref="T:Common.Drawing.TextureBrush" /> object that uses the specified image, bounding /// rectangle, and image attributes. /// </summary> /// <param name="image"> /// The <see cref="T:Common.Drawing.Image" /> object with which this /// <see cref="T:Common.Drawing.TextureBrush" /> object fills interiors. /// </param> /// <param name="dstRect"> /// A <see cref="T:Common.Drawing.Rectangle" /> structure that represents the bounding rectangle for /// this <see cref="T:Common.Drawing.TextureBrush" /> object. /// </param> /// <param name="imageAttr"> /// An <see cref="T:Common.Drawing.Imaging.ImageAttributes" /> object that contains additional /// information about the image used by this <see cref="T:Common.Drawing.TextureBrush" /> object. /// </param> public TextureBrush(Image image, Rectangle dstRect, ImageAttributes imageAttr) { WrappedTextureBrush = new System.Drawing.TextureBrush(image, dstRect, imageAttr); }
public static void GenerateBrushes(System.Drawing.Image item, System.Drawing.Image weapon, System.Drawing.Image error) { ItemToImageBrush = new Dictionary <ItemEnumeration, System.Drawing.TextureBrush>(ItemToImageTranslation.Select(kvp => new KeyValuePair <ItemEnumeration, System.Drawing.TextureBrush>(kvp.Key, new System.Drawing.TextureBrush(item, kvp.Value)))); WeaponToImageBrush = new Dictionary <Weapon, System.Drawing.TextureBrush>(WeaponToImageTranslation.Select(kvp => new KeyValuePair <Weapon, System.Drawing.TextureBrush>(kvp.Key, new System.Drawing.TextureBrush(weapon, kvp.Value)))); ErrorToImageBrush = new System.Drawing.TextureBrush(error, new System.Drawing.Rectangle(0, 0, INV_SLOT_WIDTH, INV_SLOT_HEIGHT)); }
private void DrawText() { try { if (fontItem == null) { this.imgFont.Source = null; return; } System.Drawing.Font fontText = new System.Drawing.Font(fontItem.FontName, fontItem.FontSize); System.Drawing.Size sizeText = System.Windows.Forms.TextRenderer.MeasureText(fontItem.Text, fontText, new System.Drawing.Size(0, 0), System.Windows.Forms.TextFormatFlags.NoPadding); Rect viewport = new Rect(0, 0, sizeText.Width, sizeText.Height); if ((int)viewport.Width == 0 || (int)viewport.Height == 0) { return; } System.Drawing.Bitmap tempMap = new System.Drawing.Bitmap((int)viewport.Width, (int)viewport.Height); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(tempMap); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; System.Drawing.RectangleF rect = new System.Drawing.RectangleF(0, 0, sizeText.Width, sizeText.Height); System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddString(fontItem.Text, fontText.FontFamily, (int)fontText.Style, fontText.Size, rect, System.Drawing.StringFormat.GenericDefault); //描边 g.DrawPath(new System.Drawing.Pen(new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(fontItem.StrokeColor.A, fontItem.StrokeColor.R, fontItem.StrokeColor.G, fontItem.StrokeColor.B)), fontItem.StrokeColorLength), path); //颜色 g.FillPath(new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(fontItem.FontColor.A, fontItem.FontColor.R, fontItem.FontColor.G, fontItem.FontColor.B)), path); //渐变 g.FillPath(new System.Drawing.Drawing2D.LinearGradientBrush(rect, System.Drawing.Color.FromArgb(fontItem.GradientColor1.A, fontItem.GradientColor1.R, fontItem.GradientColor1.G, fontItem.GradientColor1.B), System.Drawing.Color.FromArgb(fontItem.GradientColor2.A, fontItem.GradientColor2.R, fontItem.GradientColor2.G, fontItem.GradientColor2.B), System.Drawing.Drawing2D.LinearGradientMode.Vertical), path); //图片叠加 if (fontItem.OverlayImage != null) { System.Drawing.TextureBrush brush = new System.Drawing.TextureBrush(ImageHelper.BitmapImageToIamge(fontItem.OverlayImage), System.Drawing.Drawing2D.WrapMode.TileFlipXY);//可改变渐变方式 g.FillPath(brush, path); } path.Dispose(); BitmapImage tempImage = ImageHelper.BitmapToBitmapImage(tempMap, System.Drawing.Imaging.ImageFormat.Png); g.Dispose(); tempMap.Dispose(); if (tempImage != null) { this.imgFont.Source = tempImage; this.imgFont.Width = tempImage.Width; this.imgFont.Height = tempImage.Height; Canvas.SetLeft(this.imgFont, (this.mainCanvas.ActualWidth - tempImage.Width) / 2); Canvas.SetTop(this.imgFont, (this.mainCanvas.ActualHeight - tempImage.Height) / 2); } } catch (Exception ex) { return; } }
/// <summary> /// Initializes a new <see cref="T:Common.Drawing.TextureBrush" /> object that uses the specified image and /// bounding rectangle. /// </summary> /// <param name="image"> /// The <see cref="T:Common.Drawing.Image" /> object with which this /// <see cref="T:Common.Drawing.TextureBrush" /> object fills interiors. /// </param> /// <param name="dstRect"> /// A <see cref="T:Common.Drawing.RectangleF" /> structure that represents the bounding rectangle for /// this <see cref="T:Common.Drawing.TextureBrush" /> object. /// </param> public TextureBrush(Image image, RectangleF dstRect) { WrappedTextureBrush = new System.Drawing.TextureBrush(image, dstRect); }
/// <summary> /// Initializes a new <see cref="T:Common.Drawing.TextureBrush" /> object that uses the specified image, wrap /// mode, and bounding rectangle. /// </summary> /// <param name="image"> /// The <see cref="T:Common.Drawing.Image" /> object with which this /// <see cref="T:Common.Drawing.TextureBrush" /> object fills interiors. /// </param> /// <param name="wrapMode"> /// A <see cref="T:Common.Drawing.Drawing2D.WrapMode" /> enumeration that specifies how this /// <see cref="T:Common.Drawing.TextureBrush" /> object is tiled. /// </param> /// <param name="dstRect"> /// A <see cref="T:Common.Drawing.Rectangle" /> structure that represents the bounding rectangle for /// this <see cref="T:Common.Drawing.TextureBrush" /> object. /// </param> public TextureBrush(Image image, WrapMode wrapMode, Rectangle dstRect) { WrappedTextureBrush = new System.Drawing.TextureBrush(image, (System.Drawing.Drawing2D.WrapMode)wrapMode, dstRect); }
/// <summary> /// Initializes a new <see cref="T:Common.Drawing.TextureBrush" /> object that uses the specified image and wrap /// mode. /// </summary> /// <param name="image"> /// The <see cref="T:Common.Drawing.Image" /> object with which this /// <see cref="T:Common.Drawing.TextureBrush" /> object fills interiors. /// </param> /// <param name="wrapMode"> /// A <see cref="T:Common.Drawing.Drawing2D.WrapMode" /> enumeration that specifies how this /// <see cref="T:Common.Drawing.TextureBrush" /> object is tiled. /// </param> public TextureBrush(Image image, WrapMode wrapMode) { WrappedTextureBrush = new System.Drawing.TextureBrush(image, (System.Drawing.Drawing2D.WrapMode)wrapMode); }
/// <summary>Initializes a new <see cref="T:Common.Drawing.TextureBrush" /> object that uses the specified image.</summary> /// <param name="bitmap"> /// The <see cref="T:Common.Drawing.Image" /> object with which this /// <see cref="T:Common.Drawing.TextureBrush" /> object fills interiors. /// </param> public TextureBrush(Image bitmap) { WrappedTextureBrush = new System.Drawing.TextureBrush(bitmap); }
internal TextureBrush(System.Drawing.TextureBrush textureBrush) { WrappedTextureBrush = textureBrush; }
/// <summary> Utility method to create an appropriate <code>FillStyle</code> from a <code>Paint</code>.</summary> /// <param name="paint">an AWT <code>Paint</code> instance /// </param> /// <param name="bounds">- required for gradient ratio calculation /// </param> /// <returns> a new <code>FillStyle</code> representing the given paint /// </returns> //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" public static FillStyle build(System.Drawing.Brush paint, ref System.Drawing.RectangleF bounds, System.Drawing.Drawing2D.Matrix transform) { FillStyle fs = null; if (paint != null) { double width = (double)bounds.Width; double height = (double)bounds.Height; if (paint is System.Drawing.Color) { //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" fs = new FillStyle(SwfUtils.colorToInt(ref new System.Drawing.Color[] { (System.Drawing.Color)paint }[0])); } else if (paint is System.Drawing.Drawing2D.LinearGradientBrush) { System.Drawing.Drawing2D.LinearGradientBrush gp = (System.Drawing.Drawing2D.LinearGradientBrush)paint; //UPGRADE_ISSUE: Method 'java.awt.geom.AffineTransform.transform' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javaawtgeomAffineTransformtransform_javaawtgeomPoint2D_javaawtgeomPoint2D'" System.Drawing.PointF tempAux = System.Drawing.PointF.Empty; System.Drawing.PointF tempAux2 = System.Drawing.PointF.Empty; System.Drawing.PointF tempAux3 = transform.transform(new System.Drawing.PointF(gp.Rectangle.X, gp.Rectangle.Y), tempAux); //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" System.Drawing.PointF tempAux4 = transform.transform(new System.Drawing.PointF(gp.Rectangle.Height, gp.Rectangle.Width), tempAux2); System.Drawing.Drawing2D.Matrix gt = objectBoundingBoxTransform(ref tempAux3, ref tempAux4, width, height, width, height); fs = new FillStyle(); fs.matrix = MatrixBuilder.build(gt); fs.type = FillStyle.FILL_LINEAR_GRADIENT; fs.gradient = new Gradient(); fs.gradient.records = new GradRecord[2]; System.Drawing.Color tempAux5 = (gp.LinearColors)[0]; //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" fs.gradient.records[0] = new GradRecord(0, SwfUtils.colorToInt(ref tempAux5)); //from left System.Drawing.Color tempAux6 = (gp.LinearColors)[1]; //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" fs.gradient.records[1] = new GradRecord(255, SwfUtils.colorToInt(ref tempAux6)); //to right } else if (paint is LinearGradientPaint) { LinearGradientPaint lgp = (LinearGradientPaint)paint; System.Drawing.PointF start = lgp.getStartPoint(); System.Drawing.PointF end = lgp.getEndPoint(); //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" System.Drawing.Drawing2D.Matrix gt = objectBoundingBoxTransform(ref start, ref end, width, height, width, height); fs = new FillStyle(); fs.matrix = MatrixBuilder.build(gt); System.Drawing.Color[] colors = lgp.getColors(); float[] ratios = lgp.getFractions(); if (colors.Length == 0 || colors.Length != ratios.Length) //Invalid fill so we skip { return(null); } else if (colors.Length == 1) //Solid fill { //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" return(new FillStyle(SwfUtils.colorToInt(ref colors[0]))); } else { fs.type = FillStyle.FILL_LINEAR_GRADIENT; //Maximum of 8 gradient control points records int len = ratios.Length; if (len > 8) { len = 8; } fs.gradient = new Gradient(); fs.gradient.records = new GradRecord[len]; for (int i = 0; i < len; i++) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" fs.gradient.records[i] = new GradRecord((int)System.Math.Round((double)(255 * ratios[i])), SwfUtils.colorToInt(ref colors[i])); } } } else if (paint is RadialGradientPaint) { RadialGradientPaint rgp = (RadialGradientPaint)paint; //Note: Flash doesn't support the focal point of a radial gradient //Point2D cp = rgp.getCenterPoint(); //Point2D fp = rgp.getFocusPoint(); double diameter = rgp.getRadius() * 2.0; double outerX = diameter * rgp.getTransform().getScaleX(); double outerY = diameter * rgp.getTransform().getScaleY(); System.Drawing.PointF tempAux7 = System.Drawing.PointF.Empty; System.Drawing.PointF tempAux8 = System.Drawing.PointF.Empty; //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" System.Drawing.Drawing2D.Matrix gt = objectBoundingBoxTransform(ref tempAux7, ref tempAux8, width, height, outerX, outerY); fs = new FillStyle(); fs.matrix = MatrixBuilder.build(gt); fs.type = FillStyle.FILL_RADIAL_GRADIENT; System.Drawing.Color[] colors = rgp.getColors(); float[] ratios = rgp.getFractions(); fs.gradient = new Gradient(); fs.gradient.records = new GradRecord[ratios.Length <= 8?ratios.Length:8]; for (int i = 0; i < ratios.Length && i < 8; i++) { //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" //UPGRADE_NOTE: ref keyword was added to struct-type parameters. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1303'" fs.gradient.records[i] = new GradRecord((int)System.Math.Round((double)(255 * ratios[i])), SwfUtils.colorToInt(ref colors[i])); } } else if (paint is System.Drawing.TextureBrush) { System.Drawing.TextureBrush tp = (System.Drawing.TextureBrush)paint; System.Drawing.Image image = (System.Drawing.Image)tp.Image; DefineBitsLossless tag = DefineBitsLosslessBuilder.build(new LosslessImage(image)); //Apply Twips Scale of 20 x 20 System.Drawing.Drawing2D.Matrix at = new System.Drawing.Drawing2D.Matrix(); at.Scale((System.Single)flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL, (System.Single)flash.swf.SwfConstants_Fields.TWIPS_PER_PIXEL); Matrix matrix = MatrixBuilder.build(at); fs = new FillStyle(FillStyle.FILL_BITS, matrix, tag); } } return(fs); }
public bool setRectangleBgColor(int r, System.Drawing.Bitmap image, int CornerRadius) { if (CornerRadius > 0 && image != null) { CornerRadius *= 2; System.Drawing.Bitmap RoundedImage = new System.Drawing.Bitmap(image.Width, image.Height); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(RoundedImage); g.Clear(System.Drawing.Color.FromArgb(0,255,255,255)); g.SmoothingMode = SmoothingMode.AntiAlias; System.Drawing.Brush brush = new System.Drawing.TextureBrush(image); GraphicsPath gp = new GraphicsPath(); gp.AddArc(0, 0, CornerRadius, CornerRadius, 180, 90); gp.AddArc(0 + RoundedImage.Width - CornerRadius, 0, CornerRadius, CornerRadius, 270, 90); gp.AddArc(0 + RoundedImage.Width - CornerRadius, 0 + RoundedImage.Height - CornerRadius, CornerRadius, CornerRadius, 0, 90); gp.AddArc(0, 0 + RoundedImage.Height - CornerRadius, CornerRadius, CornerRadius, 90, 90); g.FillPath(brush, gp); image = RoundedImage; } if (activeComponents.ContainsKey(r) && activeComponents[r] is Rectangle) { try { IntPtr hBitmap = image.GetHbitmap(); System.Windows.Media.Imaging.BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( hBitmap, IntPtr.Zero, Int32Rect.Empty, System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()); ((Rectangle)activeComponents[r]).Fill = new ImageBrush(bitmapSource); } catch { return false; } return true; } return false; }