📄 imageviewer.h
字号:
/***************************************************************************
ImageViewer.h : header file for the Image Viewer tool
written by PJ Arends
pja@telus.net
For updates check http://www.codeproject.com/tools/imageviewer.asp
Version 2.3
-----------------------------------------------------------------------------
This code is provided as is, with no warranty as to it's suitability or usefulness
in any application in which it may be used.
This code may be used in any way you desire. This file may be redistributed by any
means as long as it is not sold for profit, and providing that this notice and the
author's name are included. Any modifications not made by the original author should
be clearly marked as such to remove any confusion between the original version and
any other versions.
If any bugs are found and fixed, a note to the author explaining the problem and
fix would be nice.
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Credits
=======
The ShowImageList portion was originally written by J鰎gen Sigvardsson <jorgen@profitab.com>
The ShowRegion portion was originally written by Waldermort <waldermort@hotmail.com>
The ShowGraphic portion was originally written by Morpheus Ftp <morftp@hotmail.com>
and is based on the TRACE macro written by Paul Mclachlan which is found at
http://www.codeproject.com/debug/location_trace.asp
-----------------------------------------------------------------------------
Instructions on using the Image Viewer utility
==============================================
The Image Viewer utility is used to show the contents of memory device contexts
and in memory bitmaps while you are stepping through some drawing code.
To use the image viewer utility, make sure the ImageViewer.dll file is in your
executable path, the ImageViewer.exe program is running, the ImageViewer.lib
file is in your library include path, and then simply include this file
in any file you want to use it in. This utility only works in debug builds
and you turn the tool on by #defining the 'ACTIVATE_VIEWER' macro.
ie.
#define ACTIVATE_VIEWER
#include <ImageViewer.h>
This file defines the following macros :
ShowBitmap (HBITMAP Bitmap)
ShowBitmap2 (HBITMAP Bitmap, LPCTSTR Text)
Bitmap [in] - A HBITMAP or a CBitmap object
Text [in] - A descriptive text that is accessible from the viewer
Displays the contents of an in-memory bitmap
ShowDC (HDC DC)
ShowDC2 (HDC DC, LPCTSTR Text)
DC [in] - A HDC or a CDC object
Text [in] - A descriptive text that is accessible from the viewer
Displays the contents of a memory device context
ShowGDIPlusBitmap (Gdiplus::Image Bitmap)
ShowGDIPlusBitmap2 (Gdiplus::Image Bitmap, LPCTSTR Text)
Bitmap [in] - A Gdiplus Image
Text [in] - A descriptive text that is accessible from the viewer
Displays the contents of an in memory GDI+ Image
ShowIcon (HICON Icon)
ShowIcon2 (HICON Icon, LPCTSTR Text)
Icon [in] - A HICON object
Text [in] - A descriptive text that is accessible from the viewer
Displays the contents of a HICON handle
ShowImageList (HIMAGELIST List, int Index, UINT Flags)
ShowImageList2 (HIMAGELIST List, int Index, UINT Flags, LPCTSTR Text)
List [in] - A HIMAGELIST or a CImageList object
Index [in] - Index of image in list to show, -1 for all
Flags [in] - The ILD_* flag that specifies how to display the image
Text [in] - A descriptive text that is accessible from the viewer
Displays the contents of an in-memory image list
ShowFont (HFONT Font)
ShowFont2 (HFONT Font, LPCTSTR Text)
ShowFont3 (LPCTSTR Sample, HFONT Font, LPCTSTR Text)
Font [in] - A HFONT or a CFont object
Text [in] - A descriptive text that is accessible from the viewer
Sample [in] - The text that is drawn on the final image
ShowRegion (HRGN Region)
ShowRegion2 (HRGN Region, LPCTSTR Text)
ShowRegion3 (HRGN Region, HBITMAP Bitmap, LPCTSTR Text)
ShowRegion4 (HRGN Region, HDC DC, LPCTSTR Text)
Region [in] - A HRGN or a CRgn object
Text [in] - A descriptive text that is accessible from the viewer
Bitmap [in] - The background bitmap to draw the region onto
DC [in] - The memory device context to draw the region onto
Displays the shape of a HRGN object. If a bitmap or memory device context
is supplied the region is shown by inverting the colours of the area covered
by the region, otherwise the region is shown in black on a white background.
ShowGraphic (HBITMAP Bitmap, LPCTSTR Text, ...)
ShowGraphic (HDC DC, LPCTSTR Text, ...)
ShowGraphic (HICON Icon, LPCTSTR Text, ...)
ShowGraphic (HFONT Font, LPCTSTR Text, ...)
ShowGraphic (LPCTSTR Sample, HFONT Font, LPCTSTR Text, ...)
ShowGraphic (HIMAGELIST List, int Index, UINT Flags, Text, ...)
ShowGraphic (Gdiplus::Image &GdiplusImage, LPCTSTR Text, ...)
ShowGraphic (HRGN Region, LPCTSTR Text, ...)
ShowGraphic (HRGN Region, HBITMAP BkGndBitmap, LPCTSTR Text, ...)
ShowGraphic (HRGN Region, HDC BkGndDC, LPCTSTR Text, ...)
Bitmap [in] - A HBITMAP or a CBitmap object
DC [in] - A HDC or a CDC object
Icon [in] - A HICON object
Font [in] - A HFONT or CFont object
Sample [in] - Sample text used to display the font
List [in] - A HIMAGELIST or a CImageList object
Index [in] - Index of image in list to show, -1 for all
Flags [in] - The ILD_* flag that specifies how to display the image
GdiplusImage [in] - A Gdiplus Image
Region [in] - A HRGN or a CRgn object
BkGndBitmap [in] - The background bitmap to draw the region onto
BkGndDC [in] - The memory device context to draw the region onto
Text (opt) [in] - A descriptive text that conforms to printf() style formatting
... (opt) [in] - Addition parameters for formatting the descriptive text
The ShowGraphic function is only available if using Visual Studio 7.0 (2002) or
later. The main advantage of using ShowGraphic over using the other older Show*
macros is that the optional descriptive text can be formatted using printf() style
formatting specifiers, much the same way as the MFC TRACE() function. The
ShowGraphic function is otherwise functionally identical to the other Show*
macros that have the same parameters.
If the ACTIVATE_VIEWER and _DEBUG macros are not defined, the Show* macros
are ignored, The ImageViewer.lib file is not linked, and the ImageViewer.dll
file is not loaded.
If the Image Viewer tool is active, the VIEWER_ACTIVE macro will be defined,
so you can control extra code around the Show* macros by checking for the
VIEWER_ACTIVE macro.
ie.
#ifdef VIEWER_ACTIVE
// Some code that requires the image viewer tool
#endif // VIEWER_ACTIVE
****************************************************************************/
#ifndef PJA_IMAGE_VIEWER_UTILITY_HEADER_FILE_INCLUDED
# define PJA_IMAGE_VIEWER_UTILITY_HEADER_FILE_INCLUDED
# if _MSC_VER > 1000
# pragma once
# endif // _MSC_VER > 1000
# undef VIEWER_ACTIVE
# if defined _DEBUG && defined ACTIVATE_VIEWER
# define VIEWER_ACTIVE 1
# endif // defined _DEBUG && defined ACTIVATE_VIEWER
# ifdef VIEWER_ACTIVE
# pragma comment(lib, "ImageViewer.lib")
# ifdef __cplusplus
extern "C" {
# endif // __cplusplus
// Do not call these functions directly in your code, doing so
// will cause linker and/or run time errors if the Image Viewer
// tool is turned off. Use the Show* macros instead.
__declspec(dllimport) HBITMAP GetBGBitmap(UINT, UINT);
# ifdef _UNICODE
__declspec(dllimport) LRESULT BitmapViewW(HBITMAP, LPCWSTR, UINT, LPCWSTR, LPCWSTR);
__declspec(dllimport) LRESULT IconViewW(HICON, LPCWSTR, UINT, LPCWSTR, LPCWSTR);
__declspec(dllimport) LRESULT RegionViewW(HRGN, HBITMAP, LPCWSTR, UINT, LPCWSTR, LPCWSTR);
__declspec(dllimport) LRESULT FontViewW(HFONT, LPCWSTR, LPCWSTR, UINT, LPCWSTR, LPCWSTR);
# define BitmapView BitmapViewW
# define IconView IconViewW
# define RegionView RegionViewW
# define FontView FontViewW
# else // _UNICODE
__declspec(dllimport) LRESULT BitmapViewA(HBITMAP, LPCSTR, UINT, LPCSTR, LPCSTR);
__declspec(dllimport) LRESULT IconViewA(HICON, LPCSTR, UINT, LPCSTR, LPCSTR);
__declspec(dllimport) LRESULT RegionViewA(HRGN, HBITMAP, LPCSTR, UINT, LPCSTR, LPCSTR);
__declspec(dllimport) LRESULT FontViewA(HFONT, LPCSTR, LPCSTR, UINT, LPCSTR, LPCSTR);
# define BitmapView BitmapViewA
# define IconView IconViewA
# define RegionView RegionViewA
# define FontView FontViewA
# endif // _UNICODE
# ifdef _INC_COMMCTRL
# ifdef _UNICODE
__declspec(dllimport) LRESULT ImageListViewW(HIMAGELIST, int, UINT, LPCWSTR, UINT, LPCWSTR, LPCWSTR);
# define ImageListView ImageListViewW
# else // _UNICODE
__declspec(dllimport) LRESULT ImageListViewA(HIMAGELIST, int, UINT, LPCSTR, UINT, LPCSTR, LPCSTR);
# define ImageListView ImageListViewA
# endif // _UNICODE
# endif // _INC_COMMCTRL
# ifdef __cplusplus
}
# endif // __cplusplus
# if _MSC_VER < 1300 // The __FUNCTION__ macro is only valid in VC7.0 and above
# define FUNC NULL
# else // _MSC_VER < 1300
# define FUNC _T(__FUNCTION__)
# endif // _MSC_VER < 1300
# define ShowBitmap(Bitmap) BitmapView((Bitmap), _T(__FILE__), __LINE__, FUNC, NULL)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -