system.drawing


“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))

save jpg with lower bit depth (24 to 16 for instance) (C#)

谁说我不能喝 提交于 2020-01-05 03:31:09
问题 I need to convert 24- and 32-bits jpeg and png-files to a lower bit depth (16). I found some code to do this, but the resulting images keep the bit depth of the original file although there file size is lower. Image img = Image.FromFile(filePathOriginal); Bitmap bmp = ConvertTo16bpp(img); EncoderParameters parameters = new EncoderParameters(); parameters.Param[0] = new EncoderParameter(Encoder.ColorDepth, 16); bmp.Save(filePathNew, jpgCodec, parameters); bmp.Dispose(); img.Dispose(); ...

How to convert Hexadecimal Color to RGB color (24 Bit)

落花浮王杯 提交于 2020-01-04 20:23:31
问题 I use C# and asp.net 4. How to convert and Hexadecimal Color in an equivalent RGB Color ? Example: FF0000 to 255,0,0. My aim is to pass this color to the method FromArgb namespace System.Drawing FromArgb Method (Int32, Int32, Int32) (Alpha is implicit as opaque) At the moment I use this code to Clear and Image and apply a opaque flat color: System.Drawing.Graphics.Clear(System.Drawing.Color.Red)); This works fine with predefined color like "Red", "Black" and so on, but not obviously with a

I am using .net core with C# on linux, lib System.Drawing is missing

五迷三道 提交于 2020-01-03 06:04:06
问题 Program.cs(1,14): error CS0234: The type or namespace name 'Drawing' does not exist in the namespace 'System' (are you missing an assembly reference? Is it possible to fix that? or I am not meant to be using this lib, if I am developing in Linux with C#? 回答1: The System.Drawing namespace is at the moment not part of corefx as it relies on the GDI+ features from Windows. But there are plans to support it in the future. But there are multiple alternatives: CoreCompat.System.Drawing CoreCompat

System.Drawing.DrawString() weird wrapping of long string

回眸只為那壹抹淺笑 提交于 2020-01-03 03:06:08
问题 Update: I would like to answer my own question with code that helped me solve the issue. It was submitted by Bradley but tweaked to work for me and may help others as well. But I can't answer until it is reopened. The linked duplicate provides a method, but no code. A code based answer to this question would be helpful to the community I'm having some slight issues with the formatting of the text drawn on an image inside of my console application. The text I'm trying to draw is: BAS2016=PTR

工具导航Map