gdi+

Effective way of making negative of image without external dlls

六眼飞鱼酱① 提交于 2019-12-18 17:27:46
问题 That is the solution to make a negative from a image in C# Windows Forms without any dlls and in a effective, fast way? 回答1: The best way to do this is directly accessing the pixels with bitmap data. Just to add some timing details: Performing Negate on an 8 Megapixel Image (on a 2.4 Ghz Core 2 Duo): SetPixel (~22 seconds) - 220 Times slower Color Matrix, Matajon's method below (~750 milliseconds) - 7 times slower Directly accesing the bitmap data (~100 milliseconds) - Fastest So, if you can

Effective way of making negative of image without external dlls

只愿长相守 提交于 2019-12-18 17:27:08
问题 That is the solution to make a negative from a image in C# Windows Forms without any dlls and in a effective, fast way? 回答1: The best way to do this is directly accessing the pixels with bitmap data. Just to add some timing details: Performing Negate on an 8 Megapixel Image (on a 2.4 Ghz Core 2 Duo): SetPixel (~22 seconds) - 220 Times slower Color Matrix, Matajon's method below (~750 milliseconds) - 7 times slower Directly accesing the bitmap data (~100 milliseconds) - Fastest So, if you can

Outline a path with GDI+ in .Net

蓝咒 提交于 2019-12-18 16:59:39
问题 How does one outline a graphicspath using GDI+? For example, I add two intersecting rectangles to a GraphicsPath. I want to draw the outline of this resulting graphicspath only. Note that I don't want to fill the area, I just want to draw the outline. Example: 回答1: There is no managed way to do the outline. However, GDI+ does have an function called GdipWindingModeOutline that can do exactly this. Here is the MSDN reference This code does the trick: // Declaration required for interop

Creating Custom Picturebox with Draggable and Resizable Selection Window

风流意气都作罢 提交于 2019-12-18 09:49:30
问题 I'm using the following code to draw a selection rectangle over a picturebox and allow the user to select and drag it to the desired position. What I intend to achieve is to allow the user to adjust the rectangle size by implementing option to adjust the rectangle size. Currently I have managed to achieve the following. How to solve this issue? public class DraggablePictureBox : PictureBox { Boolean hit1 = false, hit2 = false; public Boolean notagimg = true; public Boolean editedflag = false;

How to visually connect 2 circles?

a 夏天 提交于 2019-12-18 09:44:07
问题 We know 2 circle' x and y center position, and the radius is the same. I want to visually connect the circles without looping the draw ellipse for each point on the line what connect's the 2 circle's center. From this: To this: Code: int radius = 75; int x1 = 100; int y1 = 200; int x2 = 300; int y2 = 100; g.FillEllipse(Brushes.Blue, new Rectangle(x1 - radius / 2, y1 - radius / 2, radius, radius)); g.FillEllipse(Brushes.Blue, new Rectangle(x2 - radius / 2, y2 - radius / 2, radius, radius));

Draw on screen with GDI+ (or GDI) similar to Inspect

点点圈 提交于 2019-12-18 07:20:39
问题 I'm trying to draw on the screen (the whole screen, on top of every other window) using GDI+. I've passed NULL to GetDC to get a HDC to the screen, and then used that to create a Graphics object, and used DrawRectangle to draw rectangles on the screen. Everything works..except...the inside of the rectangle won't update. Like if I draw it over a command prompt, and move the command prompt, the inside of the rectangle remains black. I expect to see whats under the rectangle. Here's the code

Draw on screen with GDI+ (or GDI) similar to Inspect

独自空忆成欢 提交于 2019-12-18 07:20:35
问题 I'm trying to draw on the screen (the whole screen, on top of every other window) using GDI+. I've passed NULL to GetDC to get a HDC to the screen, and then used that to create a Graphics object, and used DrawRectangle to draw rectangles on the screen. Everything works..except...the inside of the rectangle won't update. Like if I draw it over a command prompt, and move the command prompt, the inside of the rectangle remains black. I expect to see whats under the rectangle. Here's the code

How to copy one Graphics Object into another

微笑、不失礼 提交于 2019-12-18 06:56:33
问题 I am trying to copy the contents of one graphics object to another, but the only was I have been able to find is based on using GDI32.DLL , which i would rather avoid using if possible. Does anyone know how/if this is possible using managed code? I don't mind if answers are in C# or VB.Net. Here is what I currently have: Private Sub CopyGraphics() Dim srcPic As Graphics = pnl.CreateGraphics Dim srcBmp As New Bitmap(pnl.Width, pnl.Height, srcPic) Dim srcMem As Graphics = Graphics.FromImage

Multithreading System.Windows.Graphics

自作多情 提交于 2019-12-18 06:50:44
问题 I know of course that I can not draw onto the same Graphics object from different threads, but is it also true that I can not draw to different Graphics objects in different threads? Consider the following console program: class Program { static ThreadDrawer[] drawers; static void Main(string[] args) { int numThreads = 8; drawers = new ThreadDrawer[numThreads]; for (int i = 0; i < numThreads; i++) { drawers[i] = new ThreadDrawer(); drawers[i].Start(); } for (int i = 0; i < numThreads; i++) {

Multithreading System.Windows.Graphics

混江龙づ霸主 提交于 2019-12-18 06:50:31
问题 I know of course that I can not draw onto the same Graphics object from different threads, but is it also true that I can not draw to different Graphics objects in different threads? Consider the following console program: class Program { static ThreadDrawer[] drawers; static void Main(string[] args) { int numThreads = 8; drawers = new ThreadDrawer[numThreads]; for (int i = 0; i < numThreads; i++) { drawers[i] = new ThreadDrawer(); drawers[i].Start(); } for (int i = 0; i < numThreads; i++) {