gdi

Draw a marker like google maps with TCanvas on Delphi

[亡魂溺海] 提交于 2019-12-07 03:06:09
问题 On my application I need draw on TCanvas a "marker", like Google Maps marker (see the image). I'd like use as parameters the radius, the height and the origin: I don't have idea about algorithm to use. I can use an arc to draw the top, but how can I draw the bottom? Note: I need draw it both with GDI and GDI+ so any solution is welcome. 回答1: Here is a quick example using a 200x200 PaintBox - it should at least give you an idea for the algorithm. I trust you can draw the black dot in the

Need Help Setting an Image with Transparent Background to Clipboard

江枫思渺然 提交于 2019-12-07 02:43:00
问题 I need help setting a transparent image to the clipboard. I keep getting "handle is invalid". Basically, I need a "second set of eyes" to look over the following code. (The complete working project at ftp://missico.net/ImageVisualizer.zip.) This is an image Debug Visualizer class library, but I made the included project to run as an executable for testing. (Note that window is a toolbox window and show in taskbar is set to false.) I was tired of having to perform a screen capture on the

Should we use OpenGL for 2D graphics?

孤者浪人 提交于 2019-12-07 02:05:48
问题 If we want to make an application like MS Paint, should we use OpenGL for render graphics? I want to mention about performance if using traditional GDI vs. OpenGL. And if there are exist some better libs for this purpose, please see me one. 回答1: GDI, X11, OpenGL... are rendering APIs, i.e. you usually don't use them for image manipulation (you can do this, but it requires some precautions). In a drawing application like MS Paint, if it's pixel based, you'll normally manipulate some picture

Double Buffering? Win32 c++

谁说我不能喝 提交于 2019-12-07 00:10:36
问题 I am trying to implement double buffering but it doesn't seem to work i.e. the graphic still flickers. The WM_PAINT gets called everytime when the mouse moves. (WM_MOUSEMOVE) Pasted WM_PAINT below: case WM_PAINT: { hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... RECT rect; GetClientRect(hWnd, &rect); int width=rect.right; int height=rect.bottom; HDC backbuffDC = CreateCompatibleDC(hdc); HBITMAP backbuffer = CreateCompatibleBitmap( hdc, width, height); int savedDC = SaveDC

How can I debug misleading GDI OutOfMemory exceptions?

放肆的年华 提交于 2019-12-06 22:30:28
I have a function which resizes a bitmap. It's such a "bread and butter" operation that I simply copied it from another project: private Bitmap ResizeBitmap(Bitmap orig) { Bitmap resized = new Bitmap(this.Xsize, this.Ysize, PixelFormat.Format16bppGrayScale); resized.SetResolution(orig.HorizontalResolution, orig.VerticalResolution); using (Graphics g = Graphics.FromImage(resized)) { g.DrawImage(orig, 0, 0, resized.Width, resized.Height); } return resized; } However, I kept getting OutOfMemory exceptions on Graphics g = Graphics.FromImage(resized) . I'm aware that, when it comes to GDI,

Fast library to replace CDC vector graphics

拟墨画扇 提交于 2019-12-06 16:13:08
I have a mature MFC C++ application that displays on screen and prints using CDC wrappings on the Win32 GDI. While it has been optimized over the years, I would like to replace it with something a bit faster. The graphics included rendered triangular surface models, complex polylines and polygons, and lots of text. It needs to meet the following criteria; The number of vectors displayed is likely to be very large. For example a single surface triangle is likely to generate a number lines and solid fills when rendered. At present this information is not stored anywhere, it is generated and

Resizing images in C#

一个人想着一个人 提交于 2019-12-06 15:01:04
I have the below method which I found online,which resizes an image to an approximate size, while keeping the aspect ratio. public Image ResizeImage(Size size) { int sourceWidth = _Image.Width; int sourceHeight = _Image.Height; float nPercent = 0; float nPercentW = 0; float nPercentH = 0; nPercentW = ((float)size.Width / (float)sourceWidth); nPercentH = ((float)size.Height / (float)sourceHeight); if (nPercentH > nPercentW) nPercent = nPercentH; else nPercent = nPercentW; int destWidth = (int)(sourceWidth * nPercent); int destHeight = (int)(sourceHeight * nPercent); Bitmap b = new Bitmap

Fade an image using GDI+ (i.e. Change only the Alpha channel of a TGPGraphic)

谁说胖子不能爱 提交于 2019-12-06 14:02:24
问题 I need to fade the right side of an image using GDI+. I'm actually trying to emulate the right hand side text fade that you see in Google Chrome. Here's what I want to do. Create a TGPGraphics object from a TBitmap . Create a TGPBitmap from a region of the TBitmap . Paint the background of the TGPGraphics object and the text to the TGPBitmap . Change the Alpha settings on the right hand side of the TGPBitmap object to produce the fade effect. Draw the TGPBitmap back to the TGPGraphics object.

How to draw 2d contour plot in c#?

痞子三分冷 提交于 2019-12-06 10:29:31
问题 I'm mainly interested in algorithm which would enable me to convert Point3D[] into drawable gdi lines? 回答1: Thanks to @Anders Gustafsson I was able to build something: public partial class FunctionGraph : UserControl { private Rectangle _area = new Rectangle(-10, -10, 20, 20); private Func<float, float, float> _func; public FunctionGraph() { SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles

Unable to capture data from Back Buffer (DirectX9)

风格不统一 提交于 2019-12-06 09:52:17
I am trying to find the fastest method to take the screenshot. So far I've figured out that either GDI, or DirectX can be used. Using GDI I am able to capture the screen in 35ms, while using DirectX Front buffer it takes 73ms average. I want even faster method than this. For this purpose capturing Back Buffer in DirectX seems to be a good method. I am using the following code to do the same: D3DDISPLAYMODE ddm; D3DPRESENT_PARAMETERS d3dpp; if((g_pD3D=Direct3DCreate9(D3D_SDK_VERSION))==NULL) { ErrorMessage("Unable to Create Direct3D "); return E_FAIL; } if(FAILED(g_pD3D->GetAdapterDisplayMode