gdi+

Rendering controls on glass: Solution found, needs double-buffering/perfecting

泄露秘密 提交于 2019-12-02 14:28:23
I (finally!) found a way of rendering Windows.Forms controls on glass that doesn't seem to have any major drawback nor any big implementation time. It's inspired by this article from Coded, which basically explains how to natively override the painting of controls to draw over them. I used that approach to render the control to a bitmap and paint it back with GDI+ and the appropriate alpha channel over the NativeWindow's painting area. The implementation is simple but could be perfected for usability, but that's not the point of this question. The results are, however, quite satisfying: There

Image resizing with GDI+

青春壹個敷衍的年華 提交于 2019-12-02 12:54:13
问题 I'm really trying to nail out a little more performance out of this tidbit of code. It's not a heavly used bit of code but is used every time a new image is uploaded, and 4 times for each image (100px, 200px, 500px, 700px). So when there are any more than 2 or 3 images processing, it gets a little busy on the server. Also I'm trying to figure out how to make it correctly process images with a low resolution. Currently it just chops it off half way through, not plesent. Examples: Original,

Performing Overlap Detection of 2 Bitmaps

梦想与她 提交于 2019-12-02 10:00:18
I have a custom picturebox control that allows dragging 2 bitmaps separately on the Main image,thus allowing the user to select the location of the 2 bitmaps. For First Bitmap Point src = e.Location; PointF ratio = new PointF((float)src.X / ClientSize.Width, (float)src.Y / ClientSize.Height); LaunchOrigin.textratio = ratio; Point origin = new Point((int)(backupbit1.Width * ratio.X), (int)(backupbit1.Height * ratio.Y)); LaunchOrigin.textorigin = origin; point.X = src.X - origin.X; point.Y = src.Y - origin.Y; For Second Bitmap Point src = e.Location; PointF ratio = new PointF((float)src.X /

C# LinearGradientBrush glitch when minimizing screen

家住魔仙堡 提交于 2019-12-02 09:43:53
问题 I have the following code to create a blended background on my winform: public partial class Aging : Form { protected override void OnPaintBackground(PaintEventArgs e) { using (var brush = new LinearGradientBrush(this.ClientRectangle, Color.Transparent, Color.Transparent, LinearGradientMode.Vertical)) { var blend = new ColorBlend(); blend.Positions = new[] { 0, 3 / 10f, 1 }; blend.Colors = new[] { Color.WhiteSmoke, Color.LightSteelBlue, Color.LightSteelBlue }; brush.InterpolationColors =

C# Generic GDI+ Error when using Image.Save()

时光毁灭记忆、已成空白 提交于 2019-12-02 09:25:17
问题 I am a relative novice with imaging in C#. This is my first question on this board after a very long time of being a member. I hope it can help me get through this tricky scenario. I need to read the contents (frames) of a Multi Page TIFF, saving each one into a List and finally returning it to then do some work with it. Heres my code so far public static List<Image> GetAllPages(string file) { images = new List<Image>(); using (Image img = Image.FromFile(file)) { try { for (int i = 0; i < img

Creating huge high-resolution Bitmap bigger than 23k x 23k

跟風遠走 提交于 2019-12-02 08:51:36
I want to create a huge resolution Bitmap-image so that to load it into memory and transform it based on user-gestures. I noticed that the limit for new Bitmap(int32,int32); is around 23000 but I need like 1159480 x 45920 with a bitdepth of 32. Can someone help me out or is this impossible to do? I have 8 gigs of RAM. ARE YOU REALLY SURE YOU NEED SUCH SIZE? It should be bigger than than 150GB . Moreover if you consider a point size of 1/72 of inch your image will be 409 km 500 m... EDITED If you need a high resolution image of a large area you should consider to use multiple images with

Drawing a TextBox in an extended Glass Frame w/o WPF

北城以北 提交于 2019-12-02 08:25:17
I am trying to draw a TextBox on the extended glass frame of my form. I won't describe this technique, it's well-known. Here's an example for those who haven't heard of it: http://www.danielmoth.com/Blog/Vista-Glass-In-C.aspx The thing is, it is complex to draw over this glass frame. Since black is considered to be the 0-alpha color, anything black disappears. There are apparently ways of countering this problem: drawing complex GDI+ shapes are not affected by this alpha-ness. For example, this code can be used to draw a Label on glass (note: GraphicsPath is used instead of DrawString in order

Intersecting GraphicsPath objects

情到浓时终转凉″ 提交于 2019-12-02 06:29:08
问题 How can I intersect two (.NET) GraphicsPath objects? 回答1: Are you trying to get the area enclosed by two different paths? That is a Region , not a path: var rgn1 = new Region(path1); var intersection = rgn1.Intersect(path2); rgn1.Dispose(); If that is not what you mean, you will have to provide more information. 来源: https://stackoverflow.com/questions/503376/intersecting-graphicspath-objects

When overlaying two identically-sized images, one is offset

戏子无情 提交于 2019-12-02 05:21:55
问题 I am attempting to create an image by overlaying one on top of another. The code works, but the image I am overlaying seems to be slightly stretched and I can't work out why. So the code just creates a blank red 24x24 rectangle, then I overlay a 24x24 png file which looks like this: What I am expecting is this: But I actually get this: Using backGround As New Bitmap(24, 24, Imaging.PixelFormat.Format32bppArgb) Using g = Graphics.FromImage(backGround) Using brush1 As New SolidBrush(Color.Red)

Drawing PixelFormat32bppPARGB images with GDI+ uses conventional formula instead of premultiplied one

戏子无情 提交于 2019-12-02 03:50:57
问题 Here is some minimal code to show an issue: static const int MAX_WIDTH = 320; static const int MAX_HEIGHT = 320; Gdiplus::Bitmap foregroundImg(MAX_WIDTH,MAX_HEIGHT,PixelFormat32bppPARGB); { Gdiplus::Graphics g(&foregroundImg); g.Clear(Gdiplus::Color(10,255,255,255)); } Gdiplus::Bitmap softwareBitmap(MAX_WIDTH,MAX_HEIGHT,PixelFormat32bppPARGB); Gdiplus::Graphics g(&softwareBitmap); g.SetCompositingMode(Gdiplus::CompositingModeSourceOver); g.SetCompositingQuality(Gdiplus: