gdi+

GDI+ Drawing Rectangle Is Slow

杀马特。学长 韩版系。学妹 提交于 2019-12-11 13:45:04
问题 I've developed a Windows Forms Application to draw a rectangular region relevant to the user's mouse position as he or she clicks, holds and drags the mouse. The class is very simple and is as followed: public partial class MainForm : LayeredForm { private bool drawing = false; private Point startLocation = Point.Empty; public MainForm() { InitializeComponent(); Location = Screen.PrimaryScreen.Bounds.Location; Size = Screen.PrimaryScreen.Bounds.Size; Cursor = Cursors.Cross; TopMost = true;

OutOfMemoryException with Image.Clone - Only on Windows 2003

谁说胖子不能爱 提交于 2019-12-11 13:18:35
问题 So here's my issue. I have an image that I need to shrink. The original image is a grayscale PNG, which isn't a huge issues except that when I shrink it down, the thermal label printers pickup the artifacts and print them on the label. So, what I did was change the image to black & white (Format1bppIndexed) before resizing, like this: Dim bte() As Byte = System.Convert.FromBase64String(imgStr) Dim ms As New IO.MemoryStream(bte) Dim bmp As New System.Drawing.Bitmap(ms) Dim monoImage As Drawing

GetRoundedRegion exception

╄→гoц情女王★ 提交于 2019-12-11 12:29:44
问题 I made a custom button with rounded edges, i use CreateRoundRectRgn for this, in the paint event this is called to round all the edges, when i run my program everything works fine until after about one minute, then i get the following exception(the value of p = 0): one thing to add is that the button is undergoing about 50 paint events per second because of a color fade (blinking) this is my paint event: protected override void OnPaint(PaintEventArgs e) { this.SuspendLayout(); this.Region =

Getting Same Rectangle Position from Scaled Small Size Image

人走茶凉 提交于 2019-12-11 12:18:22
问题 I'm trying to process a large size image.Since the processing takes too much time to complete i'm resizing the image prior processing.After processing i'm drawing a rectangle on the small size image.How can i translate the the coordinates of this rectangle to original unscaled image ie:Draw the rectangle at the same position on the unscaled image. I'm using the following code to resize the image public static Size ResizeKeepAspect(Size CurrentDimensions, int maxWidth, int maxHeight) { int

How to use Control.DrawToBitmap to render a Form into a Bitmap without its decorations (titlebar, border)? [duplicate]

妖精的绣舞 提交于 2019-12-11 10:43:51
问题 This question already has an answer here : Take screenshot from window content (without border) (1 answer) Closed 10 months ago . I have a Form and in it an Overlay control (transparent gray backcolor with White text over "Drop here..." and an icon) that is visible only when a file is dragged over the Form. The Overlay is made transparent by drawing the control in its back on it and then filling over with transparent gray (ARGB). The method Works very well when the Overlay should be over a

GDI+ DashStyle throws OutOfMemoryException in .NET

心已入冬 提交于 2019-12-11 10:41:51
问题 I'm using DashStyle.Dash while rendering my hierarchy of objects. My application uses Graphics.Transform extensively and I find that at some scale values (including a scale of 100%) and some angles of rotation, Graphics.DrawLine throws OutOfMemoryException when using a pen with DashStyle.Dash . Using Google I found that this is a well-known problem. Microsoft tells us that this is not a blocking issue. So far, I have not found a workaround for this problem. What are my options? 回答1: I just

Gdiplus mask image from another image

会有一股神秘感。 提交于 2019-12-11 10:36:47
问题 Is there a way to manipulate alpha of an image using alpha from another image? Suppose I have a Image and I want to alter its alpha starting opaque at left and totally transparent at right, currently I draw another image with LinearGradientBrush and set alpha of orginal image from second image by looping pixel by pixel, is there another way in Gdiplus, some image mask, or blending alpha of two images? Conclusion: it seems there is no way in GDI+ to blend two images, only way seems to be the

Mono Ignores Graphics.InterpolationMode?

旧城冷巷雨未停 提交于 2019-12-11 09:58:24
问题 I have a program that draws some vector graphics using System.Drawing and the Graphics class. The anti-aliasing works, kindof okay, but for my need I neede oversampling, so I create the starting image to be n times larger and then scale back the final image by n. On Window and .NET the resulting image looks great! However, on Mono 2.4.2.3 (Ubuntu 9.10 stock install), the intropolation is horrible. Here's how I'm scaling my images: Bitmap bmp = new Bitmap(Bmp.Width / OverSampling, Bmp.Height /

c# GDI+, Creating a LinearGradientBrush in a loop (memory leaks)

泪湿孤枕 提交于 2019-12-11 09:56:19
问题 Today I came across a bit of a dilema. I have created an app that uses GDI+ to draw on a form. The drawing is triggered by a timer every second. The draw method uses a for loop to iterate through a collection of objects and if they are of a certain state, draw them. I want to draw them using a LinearGradientBrush simply because it looks so much nicer than a simple Brush. Have a look at the following //minutes foreach (Led l in MinuteGrid.Leds) { LinearGradientBrush b = new LinearGradientBrush

Save Image from user Drawn PictureBox whose SizeMode=stretch in C# winforms

六眼飞鱼酱① 提交于 2019-12-11 08:18:53
问题 Im drawing an image on picture box which is in stretch mode,I translate the mouse coordinates on the mouse click event by using a function to obtain the real coordinates and draw the image by overriding the on-paint event and using the paint event Graphics. Since the picture box is set to stretch i only obtain a small size image when i try to save the image by using picturebox.DrawtoBitmap Function.The extra parts are padded with Black colour.Please help me out. 回答1: You can try this: using