gdi+

Compress image in .NET

折月煮酒 提交于 2019-12-30 07:12:29
问题 How can i compress and image file(*bmp,*jpeg) in C#, I have to display some images as background on my controls, i m using following code to scale my image Bitmap orgBitmap = new Bitmap(_filePath); Bitmap regBitmap = new Bitmap(reqSize.Width, reqSize.Height); using (Graphics gr = Graphics.FromImage(reqBitmap)) { gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; gr.DrawImage(bmp, new RectangleF(0, 0, reqSize.Width, reqSize.Height)); } It giving me the required bitmap. My

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

Is there an easy way to blend two System.Drawing.Color values?

萝らか妹 提交于 2019-12-30 03:47:25
问题 Is there an easy way to blend two System.Drawing.Color values? Or do I have to write my own method to take in two colors and combine them? If I do, how might one go about that? 回答1: I wrote a utility method for exactly this purpose. :) /// <summary>Blends the specified colors together.</summary> /// <param name="color">Color to blend onto the background color.</param> /// <param name="backColor">Color to blend the other color onto.</param> /// <param name="amount">How much of <paramref name=

Are GDI, GDI+ and OpenGL really obsolete/deprecated? [closed]

天大地大妈咪最大 提交于 2019-12-30 03:45:36
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . If you open the page "Graphics and Gaming (Windows)" on microsoft.com the last category is described as Legacy Graphics: Technologies that are obsolete and should not be used in new applications. This category includes (among others) the following APIs: GDI GDI+ OpenGL What's

Which Event should I use to display drawing?

こ雲淡風輕ζ 提交于 2019-12-29 09:07:30
问题 I need to put some graphics in one section of a TableLayoutPanel. I'm doing this by creating a PictureBox in one cell of the TLP. Can't get two things to work: 1) The initial display is blank! Drawing appears only when you resize the form 2) The resize event doesn't fire equally when expanding the size as compared contracting. Any suggestions to improve the above two problems would be great! Here is my code. The form has a 2x2 TableLayoutPanel in it, and one cell of the TLP has a PictureBox

How can I render a square bitmap to an arbitrary four-sided polygon using GDI?

与世无争的帅哥 提交于 2019-12-29 03:38:05
问题 I need to paint a square image, mapped or transformed to an unknown-at-compile-time four-sided polygon. How can I do this? Longer explanation The specific problem is rendering a map tile with a non-rectangular map projection. Suppose I have the following tile: and I know the four corner points need to be here: Given that, I would like to get the following output: The square tile may be: Rotated; and/or Be narrower at one end than at the other. I think the second item means this requires a non

Why not use GDI+ from ASP.NET

不打扰是莪最后的温柔 提交于 2019-12-29 00:46:09
问题 I've been told that using GDI+ from ASP.NET is dangerous and undefined. Is that because there is no guarantee of a Device Context? Can someone explain? What are some of the alternatives? Here is the MSDN source: http://msdn.microsoft.com/en-us/library/system.drawing.aspx Edit Windows and ASP.NET service ! So perhaps a normal ASP.NET application is ok? But why? Edit This is not an April Fools joke, please don't treat it as such. 回答1: There are numerous articles on the subject and it is

Custom ListView in Winforms?

折月煮酒 提交于 2019-12-28 16:05:31
问题 Is it possible to draw some strings onto a listview? I overridden the OnPaint event but I don't see any change. I checked out some code on custom listview, but it seems like people are using p/invoke, etc. Why? Isn't list as customizable as other winforms, like the Button control? I am not gonna customize wildly, just paint some more after it's done the standard painting. 回答1: class MyCustomlistView : ListView { public MyCustomlistView() : base() { SetStyle(ControlStyles.UserPaint, true); }

How to highlight wrapped text in a control using the graphics?

人走茶凉 提交于 2019-12-28 04:32:10
问题 I need to highlight the particular character in a control using the fill rect. I can get the location of the text when it's not wrapped by using the Graphics.MeasureString() method like below, var size = g.MeasureString(tempSearchText, style.Font, 0, StringFormat.GenericTypographic); If the text is wrapped then I'm not able to find the exact bounds of the character to highlight the text. I need to get the exact bounds of the given character in the text wich is wrapped. Provide your suggestion

Is there a faster alternative to GDI GetPixel()?

帅比萌擦擦* 提交于 2019-12-28 03:00:52
问题 I'm using GetPixel() from gdi32.dll in a .NET app to sample the colour of a pixel anywhere on the screen. It works ok but it is a major performance bottleneck for me. Is there a faster way of doing it? 回答1: Fast access to pixels are possible using LockBits() method of the Bitmap . This will return to you an object containing a pointer to the start of the pixel data and you can use unsafe code to access the memory. http://www.bobpowell.net/lockingbits.htm 回答2: GetPixel is slow for two reasons: