|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Region and masks
Hi,
Sorry for asking a lot of questions... It's a good way to learn, so I hope you can forgive me. I would like to make region from a mask. But I really don't want to combine rectangles for every pixel. I don't think that's a good approach. What I would like to do, is to have a layout like this: Code:
00000111111111100000 01111111111111111000 01111100011110001110 01111111111111111110 01111111110011111110 01111001111111001110 00111110000000111100 00001111111111100000 I would then like to respond to hit-tests by simply checking if the specified coordinate is 1 or 0. I would also return the bounds of the region and could also combine it with other regions, if that would be required. How can I accomplish this? It would be an "implementation" of HRGN, or something. Thanks in advance, Nille |
|
#2
|
|||
|
|||
|
Try
PtInRect() or PtInRegion() with the params from the mouse click or use GetCursor() ClientToScreen() and ScreenToClient() may be helpfull in converting the coods.
__________________
The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions. Frank Zappa |
|
#3
|
|||
|
|||
|
I want to respond to these method calls myself. Think of it like this:
Code:
|--- Rectangle
HRGN -|--- Ellipse
|--- MyImageRegion
I create a mask from a bitmap and return a valid HRGN. I then want to perform hit tests. Code:
HRGN hRgn = CreateCustomRegion("c:\\test.bmp");
if(PtInRegion(hRgn, 10, 10)) // <---- !!!
{
//...
}
I have no idea how regions work. I can image they do something like this: Code:
((SomeStruct*)hRgn)->IsPointInRegion(hRgn, x, y); The thing is, I want to do the hit test on my own, but I want the HRGN to be treated as any other HRGN. Imaging that HRGN was an abstract class, looking like this: Code:
abstract class Region
{
abstract bool PtInRegion(int x, int y);
}
You could then make your own implementation of the abstract class. This is what I want to do. I want to make my own implementation of HRGN. Is it possible? |
|
#4
|
|||
|
|||
|
Hi, I don't know if this is exactly what your looking for, but i found this code written by another programmer while i was trying to create window skins. It allows you to create a region using a bitmap and specifying the rgb value of the transparent colour.
PHP Code:
Only thing is I have no idea how this code works, maybe if someone could figure it out and explain it. I've tried askin the guy who wrote it, but it turns out it was posted like 3 years ago so he isn't replying. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > Region and masks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|