-
Notifications
You must be signed in to change notification settings - Fork 0
/
mouse.cpp
65 lines (51 loc) · 1.71 KB
/
mouse.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <vector>
#include <windows.h>
using namespace std;
using namespace cv;
int main(int argc, char** argv)
{
// Read image from file
Mat img = imread("cane.png",-1);
resize(img, img, Size(img.cols/1.5, img.rows/1.5));
//if fail to read the image
if ( img.empty() )
{
cout << "Error loading the image" << endl;
return -1;
}
/*Mat mask;
vector<Mat> rgbLayer;
split(img,rgbLayer);
Mat cs[3] = { rgbLayer[0],rgbLayer[1],rgbLayer[2] };
merge(cs,3,img);
mask = rgbLayer[3];
img.copyTo(img(cv::Rect(0,0,img.cols, img.rows)),mask);*/
//Create a window
namedWindow("Image", WINDOW_NORMAL);
resizeWindow("Image", img.cols/1.5, img.rows/1.5);
moveWindow("Image", 0, 0);
//show the image
imshow("Image", img);
//Create a window
namedWindow("Image2", WINDOW_NORMAL);
resizeWindow("Image2", img.cols/1.5, img.rows/1.5);
moveWindow("Image2", 100, 0);
//show the image
imshow("Image2", img);
HWND hwnd = FindWindow(0, "Image");
DWORD style = GetWindowLong(hwnd, GWL_STYLE);
long winLong = GetWindowLong(hwnd, GWL_EXSTYLE);
style &= ~WS_OVERLAPPEDWINDOW;
//style |= WS_POPUP;
SetWindowLong(hwnd, GWL_STYLE, style);
SetWindowLong(hwnd, GWL_EXSTYLE, winLong | WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd, RGB(255,255,255), 0, LWA_COLORKEY);
//HWND hwnd = FindWindow(0, "Image2");
//SetLayeredWindowAttributes(hwnd, 0, (255*50)/100, LWA_ALPHA);
printf("channel=%d",img.channels());
waitKey(0);
return 0;
}