system.drawing

How can I save a Panel in my form as a picture?

可紊 提交于 2019-12-04 10:13:56
I have a form that has 2 panels. I'm trying to save the contents of Panel2 as an image. I saw a thread that talked about using the screen capture to do this, but I can't find the thread anymore. Also read about using the DrawToBitMap method, but it's from visual studio 2005 info, not sure if it's the most current or suitable solution for this. So what do you recommend for saving my Panel2 as a picture, preferably a jpg? UPDATE: I implemented the code recommended below for the DrawToBitMap, but it saves half of my panel2 (the left half if that makes a difference). Because it saved half my

Possible memory leak in Zxing's System.Drawing.Bitmap

时光总嘲笑我的痴心妄想 提交于 2019-12-04 10:12:14
I am currently working with Monotouch. I have an application which opens the camera and then needs to process the image that is currently being captured. I am using code which is very similar to https://github.com/reinforce-lab/com.ReinforceLab.MonoTouch.Controls/tree/master/VideoCaptureSample/ The difference of interest between my code and theirs is that in OverlayView.cs which is placed over my UIImagePickerController however, I have the following code: using (var screenImage = CGImage.ScreenImage.WithImageInRect(Frame)) { _imageView = UIImage.FromImage(screenImage); Bitmap srcbitmap = new

Image draw speed

夙愿已清 提交于 2019-12-04 07:22:17
i am working on a game, but currently I am running benchmarks. If anyone can help me on this matter, I would greatly appreciate it. What I am doing, is I fire the paint event on a panel when I click the start button, with this code: private void startToolStripMenuItem_Click(object sender, EventArgs e) { try { pnlArea.Invalidate(); } catch (Exception) { throw; } } I then do this in my paint event: private void pnlArea_Paint(object sender, PaintEventArgs e) { try { stopwatch = new Stopwatch(); // Begin timing stopwatch.Start(); if (gameStatus == GameStatus.PlaceHead) { e.Graphics.DrawImage

C# WinForms: Drawing with one or more additional threads. How?

感情迁移 提交于 2019-12-04 05:25:28
In case I have a big drawing with all kinds of geometric forms (lines, rectangles, circles, e.t.c.) it takes a lot of time for the thread to draw everything. But in real life, one building is built by more than one workers. So if the drawing is the building and the threads are the builders, it will get drawn a lot faster. But I want to know how. Can you tell me how? Is it even possible (though I have already asked and the answer was "Yes")? Is it worth it to be used? What are the risks? If there are questions that I have missed, please tell me about them and answer them. Thanks! Assuming you

Optimising PNG output from System.Drawing in .NET [closed]

*爱你&永不变心* 提交于 2019-12-04 04:12:37
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I have a routine which reads in an image, resizes it and positions it on a new background (brand new bitmap, just the size is set).

How to draw a subpixel line

跟風遠走 提交于 2019-12-04 01:01:18
In the following code, I'm trying to draw two lines: One with a subpixel width (0.5) and the other with 1px width: var img = new Bitmap(256, 256); Graphics graphics = Graphics.FromImage(img); graphics.SmoothingMode = SmoothingMode.AntiAlias; // Draw a subpixel line (0.5 width) graphics.DrawLine(new Pen(Color.Red, (float)0.5), 0, 100, 255, 110); // Draw a single pixel line (1 width) graphics.DrawLine(new Pen(Color.Red, (float)1), 0, 110, 255, 120); img.Save(@"c:\temp\test.png", ImageFormat.Png); graphics.Dispose(); img.Dispose(); However, in the generated image, both lines appear the same width

Image manipulation in asp.net/c# without System.Drawing/GDI+

心已入冬 提交于 2019-12-03 17:17:51
问题 Is there any alternative image manipulation library for .net? I would prefer something that is managed and open source. I ask this because of two reasons: I have encountered hard to debug GDI+ errors with System.Drawing in the past I have read that using System.Drawing in asp.net web applications is not 100% supported. Thanks! edit: clarification, I know that System.Drawing can work asp.net web apps - I have used it in the past. I really just wonder if there are any managed image manipulation

Screen capture with C# and Remote Desktop problems

折月煮酒 提交于 2019-12-03 16:14:32
问题 I have a C sharp console application that captures a screenshot of a MS Word document several times. It works great, but when I place this application on a remote windows XP machine it works fine whilst I am remoted in i.e. my remote desktop is visible but if I run my app and leave remote desktop (minimize it, not even log off which I want to do ) the screenshots it takes are blank! The Screenshot app is being run by a service that runs as SYSTEM user. How can I keep the GUI alive for windows

.NET Image.Save method produces non - reproducible results on Windows 64 bit

喜欢而已 提交于 2019-12-03 12:46:49
I'm using .NET framework (tried 3.5 & 4.0) to load a .TIFF file and save it as .PNG. I expect two subsequent calls to the Save() method (using the same TIFF file) to produce the same PNG file. The produced files are, however, 'sometimes' different. The C# code below shows the problem: Image sourceToConvert = Bitmap.FromFile("c:\\tmp\\F1.tif"); sourceToConvert.Save("c:\\tmp\\F1_gen.png", ImageFormat.Png); for (int i = 0; i < 100; i++) { sourceToConvert = Bitmap.FromFile("c:\\tmp\\F1.tif"); sourceToConvert.Save("c:\\tmp\\F1_regen.png", ImageFormat.Png); if (!CompareFileBytes("c:\\tmp\\F1_gen.png

Avoiding disposing system-defined Pen and Brush instances

大憨熊 提交于 2019-12-03 11:48:10
I understand it is best practise to call Dispose() on instances of Pen and Brush , except if they've been set to the system-predefined values (eg. System.Drawing.Brushes , System.Drawing.Pens or System.Drawing.SystemBrushes ) Trying to dispose a system-defined resource results in an exception being thrown. It doesn't appear to be obvious how you can detect (apart from wrapping the Dispose() call in a try/catch) whether one of these resources is referencing a system-defined or user-defined value. There is no requirement to call Dispose . The purpose of garbage collection is to eliminate these