gdi

Get all windows which overlap my window

不想你离开。 提交于 2019-12-09 03:49:18
问题 I want to find all windows which entirely or partly overlap my window (are on top of it). As a special case, if I have two window handles (hWnd1 and hWnd2), I want to find if hWnd2 partly or completely overlaps hWnd1. The windows in question are desktop windows (not children/siblings in the same process). 回答1: Iterate the windows that might overlap yours by repeatedly calling GetWindow(), using GW_HWNDPREV. Use GetWindowRect() to check if such a window actually overlap yours. There's no

Set image meta data before save

懵懂的女人 提交于 2019-12-09 01:42:53
问题 I'm trying to set the metadata of an image on exit from a resize, the property appears to be set but after the save nothing is there. I'm pretty sure I'm doing something stupid any ideas. var pi = createPropertyItem(); pi.Id = 40091; pi.Len = "SomeText".Length; pi.Type = 2; pi.Value = Encoding.UTF8.GetBytes("SomeText"); SrcImage.SetPropertyItem(pi); SrcImage.Save(@"C:\temp\withTag.jpg"); private PropertyItem createPropertyItem() { var ci = typeof (PropertyItem); var o = ci.GetConstructor

Changing co-ordinate system

若如初见. 提交于 2019-12-08 13:18:49
问题 I need to switch from the XY co-ordinate system shown above to the X'Y' co-ordinate system using System::Drawing::Drawing2D (i.e. GDI+). This is what I have in mind: float rotation = // +90 below is because AB is the new vertical... Math::Atan2(pB.Y - pA.Y, pB.X - pA.X) * 180.0 / Math::PI + 90.0f; Matrix m; m.Translate(pA.X, pA.Y); m.Rotate(rotation); m.Invert(); array<PointF> points = gcnew array<PointF>{ pC }; m.TransformPoints(points); Is there a way to do this while minimizing rounding

how to convert windows screen coordinates to screenshot pixel coordinates?

瘦欲@ 提交于 2019-12-08 12:35:50
问题 I need to find a control on screenshot. I have its screen coordinates. How can I convert them to coordinates on screenshot? 回答1: It all depends on the size of the screenshot and the size of your current resolution. Let's say the screenshot is 800x600, but your current screen resolution is 1280x720. In order to find out the X,Y position on a 800x600 image, you need to normalize the values you have of X,Y on a 1280x720 screen. normalized_x = (x * 800) / 1280; normalized_y = (y * 600) / 720;

Best GDI drawing approach

喜你入骨 提交于 2019-12-08 11:52:35
问题 I am developing an interactive CD most of my life I wrote console applications writing something mostly graphical is akward for me. So here is my approach : I am drawing on the canavas using shapes and images the left and top position are stored in a file. Is there any easier approach ? I thought using shapes objects would simplify my work what do you guys think ? Any examples are welcome. If you consider this question subjective please vote for closing. 回答1: The proper way is to write an

Drawing to window from child thread

陌路散爱 提交于 2019-12-08 11:48:39
问题 My app has been drawing its graphics from a worker thread for over 10 years now and I've never had any problems with it. The worker thread draws to my HWND (created by the main thread) like this: hdc = GetDC(hwnd); SetDIBitsToDevice() ... or StretchDIBits() ReleaseDC(hwnd, hdc); After having ported my app to other platforms, I began to realize that drawing from any other thread than the main thread is usually a no-go on many platforms (e.g. macOS). My research has shown that this might be

Dragging points to change the shapes

那年仲夏 提交于 2019-12-08 11:35:30
问题 I have managed to connect 4 points where the mouse click is made using the following code.(I am using MFC). void CChildView::OnLButtonDown(UINT nFlags,CPoint point) { if(m_LastPoint.x!=-1 && m_iPointAmount<6) { CDC* pDC= GetDC(); pDC->MoveTo(m_LastPoint.x,m_LastPoint.y); pDC->LineTo(point.x,point.y); } m_LastPoint=point; m_iPointAmount++; } The variables are initialized in the constructor as follows. m_LastPoint.x=-1; m_LastPoint.y=-1; m_iPointAmount=1; I want to do the following now. 1

How Do I Validate a JPEG Image in C# / .Net is not corrupted

点点圈 提交于 2019-12-08 10:45:41
问题 I need to be able to validate if a JPEG image is valid and not corrupted. This is not the same as question 210650 which just asks wants to validate that it is, in fact, a JPEG image. Loading from Image with validation eg: var testJpg = Bitmap.FromStream(filename, useEmbeddedColorManagement, validateData); will not throw an exception for clipped images. Currently our solution is to try to open the file an external GD script and parse for any errors thrown from gdImageCreateFromJpeg. gdImagePtr

Static control with WS_EX_TRANSPARENT style not repainted

不想你离开。 提交于 2019-12-08 10:00:55
问题 I am trying to create a control that implements the per-pixel alpha blend while painting a 32-bit bitmap. I extended a CWnd and use static control in the resource editor. I managed to paint the alpha channel correctly but still the static control keep painting the gray background. I overwrote the OnEraseBkgnd to prevent the control from painting the background but it didn't worked. I finally managed to do it by using WS_EX_TRANSPARENT. My problem now is that my control is placed over other

Fast library to replace CDC vector graphics

自闭症网瘾萝莉.ら 提交于 2019-12-08 08:53:58
问题 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