FAQ Database Discussion Community


Bitmap from Drawing not render outside of Load_Form

c#,.net,bitmap,drawing,system.drawing
I'm trying to render bitmap created from drawing to screen but only render after minimize and maximize again. I follow these steps: Using Bitmaps for Persistent Graphics in C# But only can render bitmap in screen outside of Load_Form. If I put the code: using System.Drawing; ... Graphics graphicsObj; myBitmap...

Path.Combine on urls gives exception : The given path's format is not supported

c#,path,system.drawing,path-combine
I have an error in following code Uri imagesrc = new Uri("http://somewebsite.com/demo/images/slideshow/29.jpg"); Image image = Image.FromFile(Path.Combine("/comph/", imagesrc.ToString())); I have also tried following code - where /comph/ is my root directory Image.FromFile(Path.Combine("/comph/","http://some_other_website.com/demo/images/slideshow/29.jpg"); The above image URL is correct when I paste this URL in browser it shows the image. With the...

How to get an image from a rectangle?

c#,winforms,system.drawing
I'm making a program that's cropping images. I have two PictureBoxes and a Button named 'crop'. One picture box contains an image and when I select a rectangle in it and press 'Crop' the selected area appears in the other picture box; so the program is working when I press...

Sending file to print not working using System.Drawing.Printing

c#,asp.net,printing,system.drawing,printqueue
I'm trying to send a file to print without opening it trough Adobe as suggested by several Answers here; instead, I'm using the PrintQueue library (from System.Drawing.Printing). What I've accomplished so far: I have the correct PrintQueue referenced as pq: PrintQueue pq; //Assume it's correct. The way to get here...

Bitmap image in ASP.NET page shows strange characters

asp.net,graphics,system.drawing
I have an .aspx page (asp.net) with the following code: <%@ Page ContentType = "image/gif"%> <%@ Import Namespace = "System.Drawing" %> <%@ Import Namespace = "System.Drawing.Imaging" %> <Script Runat = "Server"> Sub Page_Load Dim objBitmap As Bitmap Dim objGraphics As Graphics objBitmap = New Bitmap(200, 200) objGraphics = Graphics.FromImage(objBitmap) objGraphics.DrawLine(new...

Heatmap style gradients in .NET

c#,.net,gradient,system.drawing,alphablending
I am trying to create a heat map with gradients that look similar to this: This image shows three points and the gradients blend nicely together. Here is what I am currently doing in my drawing function: public void DrawGradient(int x, int y, Graphics g) { using (var ellipsePath =...

Can't find embedded resource using GetManifestResourceStream

c#,stream,embedded-resource,system.drawing
I'm currently working on a Card DLL in which I would need the image files for each card as an embedded resource, the current project looks like this: Note: The card images (.png) are in the Resources folder. The code I've been trying & is pretty much the only code...

OutOfMemory exception when using Graphics.FromHwnd(…)

c#,system.drawing
I tried to directly draw to the screen with the following code: [DllImport("user32.dll")] public static extern IntPtr GetDC(IntPtr ptr); static void draw(Rectangle r, Brush b, IntPtr hwnd) { using (Graphics g = Graphics.FromHwnd(hwnd)) { g.FillRectangle(b, r); } } static void Main(string[] args) { draw(new Rectangle(0, 0, 400, 400), Brushes.PaleGoldenrod, GetDC(IntPtr.Zero));...

Rectangle.X vs Rectangle.Left

c#,.net,system.drawing
I see that the System.Drawing.Rectangle class has two sets of properties: X, Y, Width, Height Left, Top, Right, Bottom The difference between Width and Right are obvious. But I don't understand the reasoning behind the Left and Top properties. Can these be used interchangeably along with X and Y, or...