system.drawing

How much is the performence degradation caused by using Shapes derived objects instead of Visual derived objects

醉酒当歌 提交于 2019-12-10 09:24:06
问题 In creating a drawing application or a simulation containing thousands of shapes, it is advised to used classes derived from Visual (like DrawingVisual) instead of classes derived from Shape due to performance degradation. I want to know how much is the performance degradation and is majority of it due to FrameworkElement class in the hierarchy of derived classes? And what is the threshold beyond which one should decide using Visual instead of Shape? And what are the pros and cons of losing

How to manage custom fonts in web application (system.drawing)

拟墨画扇 提交于 2019-12-10 03:36:36
问题 I have an application that writes text onto images using System.Drawing (C#). I am using specific fonts to do this. Since I can't rely on my shared hosting servers to have all the custom fonts I may need (and since the list of fonts is likely to grow), how can I manage the fonts used for my application? Could I include .ttf files in my project and reference them somehow? What about a SQL database containing fonts? 回答1: It should be possible to store your font files on disk or in database, and

How to get an image from a rectangle?

こ雲淡風輕ζ 提交于 2019-12-10 03:10:54
问题 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 crop. The problem is: How can I get the image from crop area into picture box Image? Rectangle rectCropArea; Image srcImage = null; TargetPicBox.Refresh(); //Prepare a new Bitmap on which the cropped image will be drawn

How to disable subsampling with .NET / GDI+?

落花浮王杯 提交于 2019-12-09 13:25:04
问题 I am trying to save a JPEG image using the Bitmap class. I noticed that sharp edges were always blury regardless of the quality level that I specify. I figured out that it is due to subsampling of one or more of the channels. How do I disable subsampling when saving the image? I am currently using this code: EncoderParameters parameters = new EncoderParameters(1); parameters.Param[0] = new EncoderParameter(Encoder.Quality, 85L); ImageCodecInfo codec = GetEncoderInfo("image/jpeg"); image.Save

Drawing image with additive blending

流过昼夜 提交于 2019-12-09 03:07:37
问题 Question was answered. For more information, check out EDIT #4 at the end of this text. We are currently working on a gamemaking engine which is going pretty well. I am working on the Animation Creator and was wondering if it was possible to draw an image with additive blending. Let me explain. We use System.Drawing library of C# and we work with Windows Forms. For now, the user is able to create his animation by importing a framed animation image (an image containing every frame of the

Outline text with System.Drawing?

那年仲夏 提交于 2019-12-08 23:45:28
问题 I have the following code. Is there an easy way to put an outline on the text I am writing? var imageEncoder = Encoder.Quality; var imageEncoderParameters = new EncoderParameters(1); imageEncoderParameters.Param[0] = new EncoderParameter(imageEncoder, 100L); var productImage = GetImageFromByteArray(myViewModel.ProductImage.DatabaseFile.FileContents); var graphics = Graphics.FromImage(productImage); var font = new Font("Segoe Script", 24); var brush = Brushes.Orange; var container = new

How to adjust size of programatically created Bitmap to match text drawn on it?

白昼怎懂夜的黑 提交于 2019-12-08 21:50:27
I have the following .ashx page that takes some query string parameters and returns a bitmap with the specified text written on it. The problem I have is that I am currently just manually setting the initial size of the bitmap at 100 X 100 when what I really want is to have the bitmap be just big enough to include all the text that was written to it. How can I do this? public void ProcessRequest (HttpContext context) { context.Response.ContentType = "image/png"; string text = context.Request.QueryString["Text"]; //set FontName string fontName; if (context.Request.QueryString["FontName"] !=

Displaying Thumbnails of very high resolution images Fast with Minimal Delay

雨燕双飞 提交于 2019-12-08 17:02:21
问题 I need to show the preview thumbnails of high resolution images in a control for user selection. I currently use ImageListView to load images. This works fine for low to medium resolution images.But when it comes to showing thumbnails of very high resolution images there is a noticeable delay.Sample image can be downloaded from https://drive.google.com/open?id=1Qgu_aVXBiMlbHluJFU4fBvmFC45-E81C The image size is around 5000x3000 pixels and size is around 12 MB.The issue can be replicated by

Graphics.DrawImage: Out of memory exception

拈花ヽ惹草 提交于 2019-12-08 16:54:06
问题 I just can't for the life of me figure out why I'm getting an out of memory exception here, even after much research on various websites and forums. Is anyone able to shed some light on the root of all evil in this code? The exception is thrown by the call to the Graphics.DrawImage() method, line 79. [HttpPost] [ValidateAntiForgeryToken] public ActionResult EditImage(FileModel model) { var fileData = new MySite.Models.File(model.FileID, model.ClientID, ConfigurationManager.ConnectionStrings[

Translating a Point(X,Y) for Images of Different Sizes from a Custom PictureBox Control

瘦欲@ 提交于 2019-12-08 14:00:33
问题 I have to process several images in bulk.I have to place some text at a particular point(X, Y).There is a custom control that is derived from picturebox that allows the user to drag the text and place it at the desired location. There are two types of images for which I set the PictureBoxSizeMode differently Vertical Images I set > PictureBoxSizeMode.Zoom; Horizontal For Horizontal Images that fill up the PictureBox i set > PictureBoxSizeMode.StretchImage The user can select the location to