system.drawing

Drawing a contrasted string on an image

前提是你 提交于 2019-12-30 07:18:11
问题 So, I have a snapshot of a video source, which I get into an Image, grab a Graphics object for it, and then draw a timestamp in the bottom right of the image. No problem thus far. However, I cannot guarantee what colour is going to be behind the text, so no matter what brush I use, it will almost certainly clash with some of the images that it is drawn on, making the text unreadable. I am wondering if anyone knows of a way (either a method in .net, or a nice algorithm), for determining the

How to Create Subset Fonts in .NET?

岁酱吖の 提交于 2019-12-30 06:26:48
问题 I have a Silverlight application that I need to embed some less-than-common fonts in. It's simple enough for me to just copy over the TTF/OTF and compile that with my app. However, in many cases, only like 5-10 of the characters are actually used. In other cases, some font files are incredibly large ( Arial Unicode MS Regular is 22.1 MB, as an example). Fast download times of my app is really important, so optimizing the fonts used is paramount. So, what I was thinking is that I've seen in

Convert Pixels to Inches and vice versa in C#

纵然是瞬间 提交于 2019-12-30 04:38:05
问题 I am looking to convert pixes to inches and vice versa. I understand that I need DPI, but I am not sure how to get this information (e.g. I don't have the Graphics object, so that's not an option). Is there a way? 回答1: On a video device, any answer to this question is typically not very accurate. The easiest example to use to see why this is the case is a projector. The output resolution is, say, 1024x768, but the DPI varies by how far away the screen is from the projector apeture. WPF, for

How to select an area on a PictureBox.Image with mouse in C#

☆樱花仙子☆ 提交于 2019-12-29 18:51:20
问题 i just wanted to put a selection on my picturebox.image but this has just become worse than some little annoying situation. I thought on another picture box over the main picturebox but it seemed so lazy work to me. I need to know if there is a way to create a selection area (which is gonna be half transparent blue area) on a picturebox.image which im gonna draw with mouse and it shouldnt change the image im working on. sample: // Start Rectangle // private void pictureBox1_MouseDown(object

System.Drawing.Brush from System.Drawing.Color

南楼画角 提交于 2019-12-28 06:19:11
问题 I'm developing a WinForm Printing application for our company. When the document is printed, I need to take the System.Drawing.Color property of each Control on the document and create a System.Drawing.Brush object to draw it. Is there a way to convert the System.Drawing.Color value to a System.Drawing.Brush value? NOTE: I've tried looking into the System.Windows.Media.SolidColorBrush() method, but it does not seem to be helpful. 回答1: Use the SolidBrush class: using (SolidBrush brush = new

System.Drawing.Brush from System.Drawing.Color

☆樱花仙子☆ 提交于 2019-12-28 06:18:26
问题 I'm developing a WinForm Printing application for our company. When the document is printed, I need to take the System.Drawing.Color property of each Control on the document and create a System.Drawing.Brush object to draw it. Is there a way to convert the System.Drawing.Color value to a System.Drawing.Brush value? NOTE: I've tried looking into the System.Windows.Media.SolidColorBrush() method, but it does not seem to be helpful. 回答1: Use the SolidBrush class: using (SolidBrush brush = new

Selecting the size of a System.Drawing.Icon?

空扰寡人 提交于 2019-12-28 01:04:12
问题 I have a icon which has a few different sizes (16px, 32px, 64px). I am calling ToBitmap() on it, but it is always returning the 32px image. How do I retrieve the 64px one? 回答1: This is a fairly painful limitation in the ResourceManager class. Its GetObject() method doesn't provide a way to pass extra arguments that would allow selecting the returned icon by size. A workaround is to add the icon to the project instead. Use Project + Add Existing Item, select your .ico file. Select the added

c# Image resizing to different size while preserving aspect ratio

限于喜欢 提交于 2019-12-27 10:49:28
问题 I'm trying to resize an image while preserving the aspect ratio from the original image so the new image doesn't look squashed. eg: Convert a 150*100 image into a 150*150 image. The extra 50 pixels of the height need to be padded with a white background color. This is the current code I am using. It works well for resizing but changing the aspect ratio of the original image squashes the new image. private void resizeImage(string path, string originalFilename, int width, int height) { Image

Two Different GCHandle's refer to same array in memory

断了今生、忘了曾经 提交于 2019-12-25 12:45:28
问题 This is probably not a well-phrased question, because I am not sure what is happenning, so i don't know how to ask it pointedly. I am trying to learn, and i hope i can get some direction on this. Your patience with a neophyte is appreciated. I have a piece of code i am modifying. It displays an image. I want to modify the image, and display it in a different window. I copy the code that displays the image, do the modification, and it displays the modified image for both the original and

polygon with blended edges [closed]

不想你离开。 提交于 2019-12-25 07:59:06
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I'm trying to find the best way to draw polygons in C# with edges that gradually blend into the background color. I'm drawing the polygons to a bitmap, so currently I'm using the Graphics classes from System.Drawing. The polygons will be a blend mask, I have no problem to draw the