Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
8b7edda6
Commit
8b7edda6
authored
Feb 22, 2012
by
Alexander Reshetnikov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added cvShowImage working with handles under Windows.
parent
50df9565
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
0 deletions
+77
-0
window_w32.cpp
modules/highgui/src/window_w32.cpp
+77
-0
No files found.
modules/highgui/src/window_w32.cpp
View file @
8b7edda6
...
@@ -1452,6 +1452,83 @@ cvShowImage( const char* name, const CvArr* arr )
...
@@ -1452,6 +1452,83 @@ cvShowImage( const char* name, const CvArr* arr )
__END__
;
__END__
;
}
}
CV_IMPL
void
cvShowImageHWND
(
HWND
w_hWnd
,
const
CvArr
*
arr
)
{
CV_FUNCNAME
(
"cvShowImageHWND"
);
__BEGIN__
;
SIZE
size
=
{
0
,
0
};
int
channels
=
0
;
void
*
dst_ptr
=
0
;
const
int
channels0
=
3
;
int
origin
=
0
;
CvMat
stub
,
dst
,
*
image
;
bool
changed_size
=
false
;
BITMAPINFO
tempbinfo
;
HDC
hdc
=
NULL
;
if
(
!
arr
)
EXIT
;
if
(
!
w_hWnd
)
EXIT
;
hdc
=
GetDC
(
w_hWnd
);
if
(
CV_IS_IMAGE_HDR
(
arr
)
)
origin
=
((
IplImage
*
)
arr
)
->
origin
;
CV_CALL
(
image
=
cvGetMat
(
arr
,
&
stub
)
);
if
(
hdc
)
{
//GetBitmapData
BITMAP
bmp
;
GdiFlush
();
HGDIOBJ
h
=
GetCurrentObject
(
hdc
,
OBJ_BITMAP
);
if
(
h
==
NULL
)
EXIT
;
if
(
GetObject
(
h
,
sizeof
(
bmp
),
&
bmp
)
==
0
)
//GetObject(): returns size of object, 0 if error
EXIT
;
channels
=
bmp
.
bmBitsPixel
/
8
;
dst_ptr
=
bmp
.
bmBits
;
}
if
(
size
.
cx
!=
image
->
width
||
size
.
cy
!=
image
->
height
||
channels
!=
channels0
)
{
changed_size
=
true
;
uchar
buffer
[
sizeof
(
BITMAPINFO
)
+
255
*
sizeof
(
RGBQUAD
)];
BITMAPINFO
*
binfo
=
(
BITMAPINFO
*
)
buffer
;
BOOL
bDeleteObj
=
DeleteObject
(
GetCurrentObject
(
hdc
,
OBJ_BITMAP
));
CV_Assert
(
FALSE
!=
bDeleteObj
);
size
.
cx
=
image
->
width
;
size
.
cy
=
image
->
height
;
channels
=
channels0
;
FillBitmapInfo
(
binfo
,
size
.
cx
,
size
.
cy
,
channels
*
8
,
1
);
HGDIOBJ
tempImage
=
SelectObject
(
hdc
,
CreateDIBSection
(
hdc
,
binfo
,
DIB_RGB_COLORS
,
&
dst_ptr
,
0
,
0
));
}
cvInitMatHeader
(
&
dst
,
size
.
cy
,
size
.
cx
,
CV_8UC3
,
dst_ptr
,
(
size
.
cx
*
channels
+
3
)
&
-
4
);
cvConvertImage
(
image
,
&
dst
,
origin
==
0
?
CV_CVTIMG_FLIP
:
0
);
// Image stretching to fit the window
RECT
rect
;
GetClientRect
(
w_hWnd
,
&
rect
);
int
bSuccess
=
StretchDIBits
(
hdc
,
0
,
0
,
rect
.
right
,
rect
.
bottom
,
0
,
0
,
image
->
width
,
image
->
height
,
dst_ptr
,
&
tempbinfo
,
DIB_RGB_COLORS
,
SRCCOPY
);
// ony resize window if needed
InvalidateRect
(
w_hWnd
,
0
,
0
);
__END__
;
}
CV_IMPL
void
cvResizeWindow
(
const
char
*
name
,
int
width
,
int
height
)
CV_IMPL
void
cvResizeWindow
(
const
char
*
name
,
int
width
,
int
height
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment