![]() After inserting a logo on word doc.x with a transparent background, you can easily change the word doc.x to PDF. For example, when you create a painted logo, you must know how to make a transparent background in Paint? Why? Mostly, logos are applied with a transparent background to give them a sharp and shapely appearance on the doc.x. Yet, those skills are quite futile in the event that you are unable to apply some hacks to it. In my situation this worked fabulously.Don’t you love to learn a new hack in life? Well! Let’s start with ‘Paint.’ We all remember the in-built paint software in Windows computers for building our graphic skills at an early age at school. Also, the invalidating is being handled by OdGsDevice _pDevice which is a Teigha object. Notice that I am making use of Region objects. _rcLastRubberBandLine = GetSelectionRectangle(_RubberLineStart, _RubberLineEnd) _rcLastRubberBandLine.Top, _rcLastRubberBandLine.Bottom)) _pDevice.invalidate(new OdGsDCRect(_rcLastRubberBandLine.Left, _rcLastRubberBandLine.Right, Using (Region r = new Region(_rcLastRubberBandLine)) Do we need to erase the last rubber band line? (Rectangle already expanded by 2 pixels) Private void UpdateRubberBandLine(Point Location) _rcRubberBand.Top - 2, _rcRubberBand.Bottom + 2)) _pDevice.invalidate(new OdGsDCRect(_rcRubberBand.Left - 2, _rcRubberBand.Right + 2, R.Exclude(Rectangle.Inflate(_rcRubberBand, -2, -2)) Using (Region r = new Region(Rectangle.Inflate(_rcRubberBand, 2, 2))) _rcRubberBand = GetSelectionRectangle(_selectionStart, _selectionEnd) If (!_selectionStart.IsEmpty & !_selectionEnd.IsEmpty & _selectionEnd != Location) _rcLastRubberBand.Top - 2, _rcLastRubberBand.Bottom + 2)) _pDevice.invalidate(new OdGsDCRect(_rcLastRubberBand.Left - 2, _rcLastRubberBand.Right + 2, R.Exclude(Rectangle.Inflate(_rcLastRubberBand, -2, -2)) Using (Region r = new Region(Rectangle.Inflate(_rcLastRubberBand, 2, 2))) Private void UpdateRubberBandRectangle(Point Location) However, since I was using Teigha.Net as the basis of the application, in the end I went with this code: protected override void OnMouseMove(MouseEventArgs e) Here it is in Paint.Net:įor other modes, that maybe would copy the alpha channel or mix it with the previous value you would have to write routines of your own or find a lib that has it, but I think this should be all you need atm. The result is a green bitmap with a transparent hole in it. Of course you can use all DrawXXX methods including FillPath or DrawRectangle. Using (SolidBrush br = new SolidBrush(funn圜olor )) Using (Graphics g = Graphics.FromImage(bmp)) Bitmap bmp = new Bitmap(244, 244, PixelFormat.Format32bppArgb) Ĭolor funn圜olor = Color.FromArgb(255, 123, 45, 67) One simple workaround is to turn off antialiasing, draw in a weird color you don't need and then call MakeTransparent. ![]() Other modes are desirable but not supported in GDI+ drawing. Painting with transparency is unfortunately only supported in one way: By applying the RGB channels in the strenght of the alpha value. How do I draw just the rectangle? What am I missing? I am sorry if this is a dumb question! ![]() So it is obliterating the drawing underneath that is on the bitmap: The problem is that the rectangle is drawing with a black background. _Graphics.DrawString(ex.ToString(), new Font("Arial", 16), new SolidBrush(Color.Black), new PointF(150.0F, 150.0F)) Į.Graphics.DrawImageUnscaled(_Bitmap, 0, 0) Properties.putAt("WindowHDC", new OdRxVariantValue(_Graphics.GetHdc().ToInt32())) // hWnd necessary for DirectX device ("WindowHDC", new RxVariant((Int32)graphics.GetHdc())) OdRxDictionary Properties = _graphicsDevice.properties() _Graphics.FillPath(Brushes.WhiteSmoke, gp) Using (GraphicsPath gp = new GraphicsPath()) _Graphics.DrawRectangle(_selectionPen, _rcRubberBand) In my handlers OnPaint method it does this: protected override void OnPaint(PaintEventArgs e) I thought that I might have to manually set the bitmap as transparent. ![]() _Graphics.FillRectangle(Brushes.Transparent, Bounds) _Bitmap.MakeTransparent(Color.Transparent) _Bitmap = new Bitmap(Bounds.Width, Bounds.Height) If (_Graphics != null) _Graphics.Dispose() So I create a bitmap: if (_Bitmap != null) _Bitmap.Dispose() ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |