system.drawing

When constructing a Bitmap with Image.FromHbitmap(), how soon can the original bitmap handle be deleted?

坚强是说给别人听的谎言 提交于 2020-07-06 11:41:16
问题 From the documentation of Image.FromHbitmap() at http://msdn.microsoft.com/en-us/library/k061we7x%28VS.80%29.aspx : The FromHbitmap method makes a copy of the GDI bitmap; so you can release the incoming GDI bitmap using the GDIDeleteObject method immediately after creating the new Image. This pretty explicitly states that the bitmap handle can be immediately deleted with DeleteObject as soon as the Bitmap instance is created. Looking at the implementation of Image.FromHbitmap() with Reflector

GDI+ performance tricks [closed]

为君一笑 提交于 2020-06-24 04:02:18
问题 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 8 years ago . Does anyone know of any reliable (and, hopefully, extensive) books/websites that discuss GDI+ performance (beyond the obvious)? For

How to resize a cropped image?

十年热恋 提交于 2020-06-01 04:07:49
问题 Goal: My current goal is to crop the original image from pictureBox1 and show it in pictureBox2 and increase it's size (Height & Width) by 0.8 . Current Code: //... private Point LocationXY; private Point LocationX1Y1; private void button1_Click(object sender, EventArgs e) { if (Clipboard.ContainsImage()) { pictureBox1.Image?.Dispose(); pictureBox1.Image = Clipboard.GetImage(); } } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if(e.Button == MouseButtons.Left)

How to resize a cropped image?

廉价感情. 提交于 2020-06-01 04:07:12
问题 Goal: My current goal is to crop the original image from pictureBox1 and show it in pictureBox2 and increase it's size (Height & Width) by 0.8 . Current Code: //... private Point LocationXY; private Point LocationX1Y1; private void button1_Click(object sender, EventArgs e) { if (Clipboard.ContainsImage()) { pictureBox1.Image?.Dispose(); pictureBox1.Image = Clipboard.GetImage(); } } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if(e.Button == MouseButtons.Left)

“Parameter is not valid” exception from System.Drawing.Image.FromStream() method

偶尔善良 提交于 2020-01-24 03:51:43
问题 I got a hard time with the Image.FromStream method in my website. The code below works perfect on my computer. But when I uploaded it to the test server, it always gives me "Parameter not valid" exception. if (!afuImageFile.IsUploading && afuImageFile.HasFile) { System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent); } the afuImageFile is an AsynFileUploader control in Ajax Tool Kits. afuImageFile.FileContent is a HttpInputStream . I guess I need to add some

How to convert WMF to EMF+ with GdipConvertToEmfPlus without losing three-quarter of image?

点点圈 提交于 2020-01-17 02:27:11
问题 After converting WMF to EMF+ in order to get anti-aliased rendering, only the upper left quadrant of my WMF is included after conversion to EMF+. Drawing the WMF (before conversion) with EnumerateMetafile works, but doesn't anti-alias, which is what I'm gunning for here. Any ideas why three quarters of the image is lost on conversion? The WMF was generated by AutoCAD LT and 32640x14586 pixels sized, with units/inch=1632. The record types in the EMF (after conversion) are: EmfMin Header

How to print bitmap without zoom from MVC controller in Debian

前提是你 提交于 2020-01-14 06:52:09
问题 Document is printed from MVC controller to Debian Squeeze Linux server printer using code below in Mono. Page in printer is A4. Printed text in paper is too big and unsharp. Rightmost part of text is not visible since it does not fit to page. If printed from Windows from .NET to HP Laserjet, output is correct. So it looks like Mono or Samsung ML-331x Series printer zooms bitmap for unknown reason which causes too big and unsharp output. How to fix this so that bitmap is printed like in

How to print bitmap without zoom from MVC controller in Debian

杀马特。学长 韩版系。学妹 提交于 2020-01-14 06:52:00
问题 Document is printed from MVC controller to Debian Squeeze Linux server printer using code below in Mono. Page in printer is A4. Printed text in paper is too big and unsharp. Rightmost part of text is not visible since it does not fit to page. If printed from Windows from .NET to HP Laserjet, output is correct. So it looks like Mono or Samsung ML-331x Series printer zooms bitmap for unknown reason which causes too big and unsharp output. How to fix this so that bitmap is printed like in

Drawing on the Desktop using C#

烈酒焚心 提交于 2020-01-06 20:20:14
问题 I'm trying to draw a rectangle right on the desktop using C#. After finding some solutions and I got these: using System; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; namespace Test { public partial class Form1 : Form { [DllImport("User32.dll")] public static extern IntPtr GetDC(IntPtr hwnd); [DllImport("User32.dll")] static extern int ReleaseDC(IntPtr hwnd, IntPtr dc); public Form1() { InitializeComponent(); } private void Form1_Load(object sender,

Merge an image, a background and Text into a single image

与世无争的帅哥 提交于 2020-01-06 15:08:06
问题 I found this code here: Private _BackgroundColours As New List(Of String)() From { _ "339966", _ "3366CC", _ "CC33FF", _ "FF5050" _ } Public Function GenerateRactangle(firstName As String, lastName As String) As MemoryStream Dim imgSize() As Integer = {800, 800} Dim avatarString As String = String.Format("{0}{1}", firstName(0), lastName(0)).ToUpper() Dim bgColour = _BackgroundColours(New Random().[Next](0, _BackgroundColours.Count - 1)) Dim bmp As Bitmap = New Bitmap(imgSize(0), imgSize(1))