gdi+

How do I superimpose one bitmap image on another in GDI+?

我只是一个虾纸丫 提交于 2019-12-10 16:43:46
问题 Using GDI+ I've made a heatmap bmp and I'd like to superimpose it on top of my bmp map. I've saved the two bmps to disk, and they look good, I just need a way to put them together. Is there any way to do this, perhaps using the Graphics object? How is transparency/alpa involved? I'm very new to GDI programming so please be as specific as possible. OK - here's an answer. At some point I need to learn how GDI+ works... I couldn't get around the transarency issues, but this works. It just copies

How to create a RectangleF using two PointF?

蓝咒 提交于 2019-12-10 14:53:14
问题 I have two points created, like a line. I want to convert it as a rectangle. How should I do it? For example this is how I draw the line. But I want it to be a Rectangle private PointF start, end; protected override void OnMouseDown(MouseEventArgs e) { start.X = e.X; start.Y = e.Y; } protected override void OnMouseUp(MouseEventArgs e) { end.X = e.X; end.Y = e.Y; Invalidate(); } 回答1: How about: new RectangleF(Math.Min(start.X, end.X), Math.Min(start.Y, end.Y), Math.Abs(start.X - end.X), Math

TextRenderer.DrawText using GDI to render OTF Fonts?

谁都会走 提交于 2019-12-10 14:33:34
问题 I'm trying to draw text over a bitmap image and I've done some research and found that .NET/GDI+ doesn't support OTF fonts. I read somewhere that you could use TextRenderer.DrawText to render OTF fonts with GDI, but I can't seem to figure out how, nor does the quality compare to Graphics.DrawString in the least bit. First of all, is it possible to use OTF fonts at all in VS or did I read something incorrectly? Second, If the answer is TextRenderer.DrawText, how do I use the OTF fonts? It

Program hangs when unloading a DLL making use of GdiPlus

眉间皱痕 提交于 2019-12-10 13:46:43
问题 I have an application which load a DLL that makes use of Delphi GDI+ Library. This application hangs when it unload the DLL (Calling FreeLibrary). I tracked the issue down to GdiPlus.pas unit finalization section which calls GdiPlusShutdown which never returns. How to avoid this deadlock? 回答1: The documentation for the GdiplusStartup function says this: Do not call GdiplusStartup or GdiplusShutdown in DllMain or in any function that is called by DllMain . If you want to create a DLL that uses

Prevent repainting of window in C++

故事扮演 提交于 2019-12-10 12:57:54
问题 I am writing a global hook DLL that needs to do some drawing using GDI+ on a window in response to an event. My problem is that the window that is being drawn keeps repainting itself, so what I draw gets erased before I want it to. Is there any way I can prevent the window from painting anything for as long as I need to? My hook currently is a WH_CALLWNDPROC hook. The drawing is done using GDI+ in response to the message WM_SIZING . I drawing using GDI+ onto the window's DC (i.e. GetWindowDC

TextBox drawn in WM_PAINT flickers on mouse enter/leave

百般思念 提交于 2019-12-10 12:19:35
问题 I have a custom TextBox in which I draw some place holder text when it's empty. It works pretty well, but it flickers when the mouse enters and leaves the TextBox. It seems related to the border becoming blue when the mouse hovers the control (I'm on Windows 8.1). Any idea how I could fix this ? I've tried various SetStyles flags without success. class MyTextBox : TextBox { public string PlaceHolder { get; set; } static readonly Brush sPlaceHolderBrush = new SolidBrush(Color.FromArgb(70, 70,

How to fill the linear gradient brush region from the original region?

巧了我就是萌 提交于 2019-12-10 11:57:00
问题 I’m using LinearGradient brush to fill the region and I created the linearGradient brush using starting and ending points, Color. Rectangle linearGradientregion= new Rectangl(20,-50,30,30); LinearGradientBrush linearGradientBrush = new LinearGradientBrush(new PointF(20, -20), new PointF(50, -50), Color.Green, Color.Red); Rectangle pathRegion= new Rectangl(-50,-25,50,50); GraphicsPath path = new GraphicsPath(); path.AddRectangle(pathRegion); graphics.FillPath(linearGradientBrush, path); And

Replace/Redraw a TextBox 3D border using a custom color

不羁岁月 提交于 2019-12-10 11:55:51
问题 SCENARIO In WinForms , I've sub-classed a Textbox to draw my own border with a solid color when BorderStyle property is set to Flat , None , or Fixed3D . PROBLEM When I try to draw a border with a color when my TextBox property is set Fixed3D , the border is not properly drawn on the surface: What you see in the image is a zoomed TextBox with: BackColor = Black BorderStyle = Fixed3D (the white thing) And the red thing is my intent of border. QUESTION In C# or VB.Net, how I can replace/redraw

“A generic error occurred in GDI+” error while showing uploaded images

99封情书 提交于 2019-12-10 11:45:34
问题 i am using the following code to show the image that has been saved in my database from my asp.net mvc(C#) application:. public ActionResult GetSiteHeaderLogo() { SiteHeader _siteHeader = new SiteHeader(); Image imgImage = null; long userId = Utility.GetUserIdFromSession(); if (userId > 0) { _siteHeader = this.siteBLL.GetSiteHeaderLogo(userId); if (_siteHeader.Logo != null && _siteHeader.Logo.Length > 0) { byte[] _imageBytes = _siteHeader.Logo; if (_imageBytes != null) { using (System.IO

How to generate dynamic C# images? [closed]

强颜欢笑 提交于 2019-12-10 11:25:35
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Basically, I want to rehash VisualCube, written previously in PHP. I've looked into GDI+, tried to find books that dealt with C#, graphics, etc. Everything somewhat relevant is aimed at only WinForms or WPF, while I'd ideally want to create a WebAPI or WCF service that serves up the images. What technologies can