(C++) How to use GetPixel() of x y on screen [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Could someone make some code that gets the pixel of an x y coord on screen and explain how the code works. I have read other examples but I dont know what all the functions and code do. Thanks.

HDC hdcScreen = GetDC(0);
COLORREF crPixel = GetPixel(hdcScreen, 10, 10);
ReleaseDC(0, hdcScreen);
Will store the displayed pixel at coordinates 10,10 into crPixel.
Is this what you were asking for?

Related

Meaning of dx and dy in MOUSEEVENTF_LEFTDOWN [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to simulate mouse clicks for my opencv project in C++. I am using mouse_event(), and I do not understand the meaning of the dx and dy parameters when sending MOUSEEVENTF_LEFTDOWN events.
Are the terms "absolute" and "relative" used in documentation related to screen or cursor?
The dx and dy parameters can refer to either absolute or relative coordinates.
If you don't want the mouse to move, set them both to 0 and make sure you don't set the MOUSEEVENTF_ABSOLUTE flag (that is; you need to use relative coordinates, since adding 0 to the existing position results in no change).
Also note that mouse_event is deprecated; you should be using SendInput instead.

position button in window depending on window size [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am creating this game in Visual Studio for my school project using SFML to render and create sprite.
I have created this button which I currently places at
x=1000, y = 600 on my screen size.
I have retina display macbook.
I tested the position of the button and it changes it's location depending on the screen size. if the screen size is something smaller then my x and y then button would not even show on the screen so how would i make it dynamic for all the different screens and how can i make it scale to the same size in different sizes.
thanks,
Start with sf::VideoMode::GetDesktopMode() to determine the size of the desktop you're running on and divide/multiply your button coordinates appropriately. You could also approach the scaling problem with sf::Views - http://www.sfml-dev.org/tutorials/2.2/graphics-view.php

When should SelectFont be Called? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I was fixing an issue to do with scaling and the solution was that we had to call SelectFont afer DrawText.
If SelectFont is called before DrawText the font isn't scaled correctly.
I cant see how that would make a difference, is there any reason?
SelectFont essentially selects a font in the Device Context you pass in. If you call DrawText before selecting a font, then a default font (System) will be used and not the font you want to select.
This means that the font you are using isn't scaling well as the results seem better with the default system font.

Drawing to a GDI+ Bitmap [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am trying to move everything from GDI to GDI+. As it stands I am drawing to a buffer DC (GDI). I am wanting to have it instead drawn to a HBITMAP and only have it drawn once. I have tried
things with pointers and Image, but could not find anything useful. There is no istream or file, and I am not using the flat api version (found a constructor for that.)
http://pastebin.com/bcw07Suq
Solved. Here is how you can create the bitmap and then proceed to draw.
Graphics g(hDC);
Bitmap foobar(100,100,PixelFormat32bppPARGB);
g.DrawImage(&foobar,100,100);
SolidBrush brush(Color::Blue);
g.FillRectangle(&brush, 0,0,10,10);

How can I make zoomable square table in SFML? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
How can I make zoomable square table like in the picture below?
At first, there is no tile in squares.
but when zoom in, tiles are slowly appearing inside squares.
And another question, can I have paint bucket tool and use to fill my tile then store information into array?
In SFML this can be done using a so-called sf::View. This allows you to have a world defined and have different and changing views on it, like in your example.
There is a very good introduction to Views in SFML here.