[译]图像查看器实用程序
By robot-v1.0
本文链接 https://www.kyfws.com/applications/image-viewer-utility-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 25 分钟阅读 - 12274 个词 阅读量 0[译]图像查看器实用程序
原文地址:https://www.codeproject.com/Articles/1655/Image-Viewer-Utility
原文作者:PJ Arends
译文由本站 robot-v1.0 翻译
前言
A little utility program that allows you to view the contents of memory bitmaps and device contexts while you are stepping through your drawing code.
一个小的实用程序,可让您在逐步执行绘图代码时查看内存位图和设备上下文的内容.
- 下载图像查看器实用程序-118 Kb(Download Image Viewer utility - 118 Kb)
- 下载演示项目和完整源代码-223 Kb(Download demo project and full source code - 223 Kb)
显示图像列表内容的Image Viewer应用程序(The Image Viewer application showing the contents of an image list)
内容(Contents)
介绍(Introduction)
您是否曾经调试过一个图形例程,在其中确实希望查看在执行代码时在内存中使用的图像的实际外观?好吧,现在您可以!!!(Have you ever debugged a graphics routine where you would really like to see what the images you are working with in memory actually looked like while you are stepping through your code? Well, now you can!!!)
的(The)图像浏览器(Image Viewer)是一个简单的实用程序,您可以将其插入绘图代码.它具有缩放功能,因此您可以真正近距离查看正在绘制的内容,或者更好地查看较大的图片.用它偷看(is a simple utility program that you can plug into your drawing code. It has a zoom feature so you can get a real close look at what you are drawing, or a good overview of a larger picture. Use it to peek at) HDC
s(s,) HBITMAP
s(s,) HICON
s(s,) HCURSOR
s(s,) HFONT
s(s,) HIMAGELIST
s(s,) HRGN
s和(s, and) Gdiplus::Image
s.(s.)
Image Viewer下载仅包含编译的文件和(The Image Viewer download contains just the compiled files and the)**ImageViewer.h(ImageViewer.h)**头文件.演示应用程序下载包含所有源代码.(header file. The demo application download contains all the source code.)
的(The)**ImageViewer.h(ImageViewer.h)**头文件和(header file and the)**ImageViewer.dll(ImageViewer.dll)**库文件都只使用Win32 API和一些ATL编写.不使用MFC.头文件和库文件均已使用MBCS和Unicode构建与Visual C ++ 6.0和Visual C ++ 8.0进行了测试.(library file were both written using only the Win32 APIs and some ATL. MFC was not used. Both the header and library files have been tested with Visual C++ 6.0 and Visual C++ 8.0, using both MBCS and Unicode builds.)
系统要求(System Requirements)
因为Image Viewer应用程序是32位MFC 8.0 Unicode应用程序,所以您将需要在计算机上安装Visual C ++ 8.0运行时才能使用它.运行时可以从(Because the Image Viewer application is a 32 bit MFC 8.0 unicode application you will need the Visual C++ 8.0 runtimes installed on your machine in order to use it. The runtimes can by obtained from the) 微软网站(Microsoft website) .请按照该页面上的说明下载并安装(. Follow the directions on that page to download and install the)**vcredist_x86.exe(vcredist_x86.exe)**运行时安装程序.图像查看器应用程序还利用GDI +.如果您运行的是Windows 2000,则可能必须下载并安装可从以下网站获得的GDI +可再发行文件:(runtime installer. The Image Viewer application also makes use of GDI+. If you are running Windows 2000 you may have to download and install the GDI+ redistributable files available from the) 微软网站(Microsoft website) .(.)
安装文件(Installing the files)
没有提供安装程序,因此必须将文件手动复制到硬盘驱动器上的正确位置.所有必需的文件都包含在(There is no installer provided, so the files have to be manually copied to the proper locations on your hard drive. All the neccessary files are contained in the) 图像查看器实用程序下载(Image Viewer utility download) 文件.(file.)
文件(FILE) | 在文件夹中(IN FOLDER) |
---|---|
ImageViewer.h | Dev Studio \ VC \ Include(Dev Studio\VC\Include) |
ImageViewer.dll | WindowsorWINNT |
ImageViewer.lib | Dev Studio \ VC \ Lib(Dev Studio\VC\Lib) |
ImageViewer.exe | Dev Studio \ Common \ Tools(Dev Studio\Common\Tools) |
如何使用图像查看器(How to use the Image Viewer)
使用该实用程序非常轻松.只需包括(Using the utility is pretty painless. Simply include the)**ImageViewer.h(ImageViewer.h)**包含绘图代码的源文件中的头文件.您可以通过定义(header file in the source file you have your drawing code in. You turn the viewer on by defining the) ACTIVATE_VIEWER
宏.(macro.)
// viewer active
#define ACTIVATE_VIEWER
#include <span class="code-string">"ImageViewer.h"</span>
要么(or)
// viewer not active
// #define ACTIVATE_VIEWER
#include <span class="code-string">"ImageViewer.h"</span>
如果(If) ACTIVATE_VIEWER
已定义,并且您在调试模式下工作,(is defined, and you are working in debug mode, the)**ImageViewer.h(ImageViewer.h)**文件将导致您的程序链接到(file will cause your program to link to the)**图像查看器库(ImageViewer.lib)**文件,当您的程序执行时,它将加载(file, and when your program executes, it will load the)**ImageViewer.dll(ImageViewer.dll)**文件.(file.)
要实际查看图像,您必须运行(To actually view the images, you have to run the)**图像查看器(ImageViewer.exe)**程序. DLL将使用以下命令将要查看的位图发送到Viewer应用程序:(program. The DLL will send the bitmap to be viewed to the Viewer application using a) WM_COPYDATA
信息.(message.)
在您的绘图代码中,调用其中一个(In your drawing code, place a call to one of the) Show*
当您想窥视图像时可以使用此功能.(functions whenever you want to take a peek at an image.)
CDC memDC;
memDC.CreateCompatibleDC(NULL);
// some drawing code
ShowDC(memDC); // take a peek at what is drawn so far
// some more code etc.
如果图像查看器工具处于活动状态,则(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.)
#ifdef VIEWER_ACTIVE
// Some code that requires the image viewer tool
#endif // VIEWER_ACTIVE
API宏(The API Macros)
该API包含以下宏:(The API consists of the following macros:)
ShowBitmap (HBITMAP bmp)
ShowBitmap2 (HBITMAP bmp, LPCTSTR Text)
ShowDC (HDC DC)
ShowDC2 (HDC DC, LPCTSTR Text)
ShowGDIPlusBitmap (Gdiplus::Image)
ShowGDIPlusBitmap2 (Gdiplus::Image, LPCTSTR Text)
ShowIcon (HICON icon)
ShowIcon2 (HICON icon, LPCTSTR Text)
ShowCursor (HCURSOR cursor)
ShowCursor2 (HCURSOR cursor, LPCTSTR Text)
ShowFont (HFONT Font)
ShowFont2 (HFONT Font, LPCTSTR Text)
ShowFont3 (LPCTSTR Sample, HFONT Font, LPCTSTR Text)
ShowImageList (HIMAGELIST List, int Index, UINT Flags)
ShowImageList2 (HIMAGELIST List, int Index, UINT Flags, LPCTSTR Text)
ShowRegion (HRGN Region)
ShowRegion2 (HRGN Region, LPCTSTR Text)
ShowRegion3 (HRGN Region, HBITMAP Bitmap, LPCTSTR Text)
ShowRegion4 (HRGN Region, HDC DC, LPCTSTR Text)
所有这些宏都返回一个(All these macros return a)LRESULT
代表Win32错误代码的值.可能的返回码说明如下.(value that represents a Win32 error code. The possible return codes are explained below.)
的(The) ShowBitmap()
,(,) ShowDC()
和(, and) ShowGDIPlusBitmap()
函数将按原样显示图像.(functions will show the image “as-is”.)
看一个(To watch a) Gdiplus::Graphics
您可能正在处理的对象,请使用(object that you may be working on, create it with an) Image
,然后看(, and watch that) Image
.(.)
Image bmp(width, height);
Graphics g(bmp);
g.DrawImage(Picture, 0, 0);
ShowGDIPlusBitmap(bmp); // take a peek at what is drawn.
的(The) ShowIcon()
和(and) ShowCursor
功能将图标或光标显示为三部分的水平图像.最左边的部分是(functions show the icon or cursor as a three part horizontal image. The left most part is the) AND
面具,中间是(mask, the middle is the) XOR
遮罩,最右边的部分是绘制时将出现的实际图标或光标.(mask, and the right most part is the actual icon or cursor as it will appear when drawn.)
带有光标的Image Viewer应用程序(The Image Viewer application with a cursor)
的(The) ShowImageList()
该功能最初由Jrgen Sigvardsson编写,其工作原理略有不同,因为它需要三个参数.它们是图像列表的句柄,列表中图像的索引和自定义(function, which was originally written by Jrgen Sigvardsson, works a little differently as it takes three parameters. They are the image list’s handle, the index of the image in the list, and a custom) ILD_*
显示标志.索引可以是-1,也可以是图像列表的合法索引.指定-1作为索引将绘制整个图像列表.该图像绘制了三遍:(display flag. The index may be -1, or a legal index for the image list. Specifying -1 as the index will draw the entire image list. The image is drawn three times:) ILD_NORMAL
在上面,(on top,) ILD_TRANSPARENT
在中间,底部是使用自定义绘制的(in the middle, and the bottom is drawn using the custom) ILD_*
标志参数.(flags parameter.)
随着(With the) ShowRegion
函数基于WalderMort提供的代码,可以在默认背景上以黑色显示HRGN,或者如果以HBITMAP或HDC提供背景图像,则通过反转背景像素来显示HRGN所提供的HRGN中的图像.(functions, which are based on code supplied by WalderMort, it is possible to show the HRGN in black on the default background, or if a background image is supplied as either a HBITMAP or HDC the HRGN will be shown by inverting the pixels of the background image that are within the supplied HRGN.)
图像查看器通过反转位图的颜色显示HRGN区域(Image Viewer showing an HRGN region by inverting the colours of a bitmap)
函数的第二个版本(The second version of the functions take a) LPCTSTR
指向描述性文本的指针,可以在查看图像时稍后从Image Viewer应用程序访问它.它将在子框架状态栏中看到,也可以在属性对话框中看到. “属性"对话框还显示以像素为单位的图像大小,图像的位深度以及源文件和行号,其中(pointer to a descriptive text that can be accessed later from the Image Viewer application when viewing the image. It will be seen in the child frames status bar and can also be seen in the properties dialog. The Properties dialog also shows the image size in pixels, the bit-depth of the image, and the source file and line number where the) Show*
宏被调用.(macro was called.)
图像属性对话框(The image properties dialog)
ShowGraphic()API函数(ShowGraphic() API function)
的(*The*) ShowGraphic
该功能是2.2版中的新增功能.它旨在替代所有先前列出的产品(function is new in version 2.2. It is designed to replace all the previously listed*) Show*
功能.问题在于它使用了(functions. The problem with it is that it uses the*) __noop)__noop( 关键字,因此在旧版本的Visual C ++中不起作用.的(keyword so it does not work in older versions Visual C++. The) ShowGraphic
函数需要Visual C ++ 7.0或更高版本.的代码(function requires Visual C++ version 7.0 or later. The code for the) ShowGraphic
功能基于(function is based on the) 位置追踪(Location Trace) 文章作者(article by) [保罗麦克拉克兰(*Paul Mclachlan*)](http://www.codeproject.com/script/Articles/list_articles.asp?userid=144146) 最初是由Mor FTP为此功能改编的.的主要优点之一(*that was originally adapted for this function by Mor FTP. One of the main advantages of*)
ShowGraphic就是通过使用运算符重载,一个功能现在可以显示许多不同的图形对象.另一个主要优点是,现在可以使用(*is that by using operator overloading one function can now show many different graphics object. The other main advantage is that the descriptive text can now be specified using*)
printf` 样式格式.(style formatting.)
此处列出了各种重载.(The various overloads are listed here.)
LRESULT ShowGraphic(HBITMAP hBitmap, LPCTSTR Format = NULL, ...)
LRESULT ShowGraphic(HDC hDC, LPCTSTR Format = NULL, ...)
LRESULT ShowGraphic(HICON hIcon, LPCTSTR Format = NULL, ...)
LRESULT ShowGraphic(HCURSOR hCursor, LPCTSTR Format = NULL, ...)
LRESULT ShowGraphic(HFONT hFont, LPCTSTR Format = NULL, ...)
LRESULT ShowGraphic(LPCTSTR Sample, HFONT hFont, LPCTSTR Format = NULL, ...)
LRESULT ShowGraphic(HIMAGELIST hList, LPCTSTR Format = NULL, ...)
LRESULT ShowGraphic(HRGN hRgn, LPCTSTR Format = NULL, ...)
LRESULT ShowGraphic(HRGN hRgn, HBITMAP hBitmap, LPCTSTR Format = NULL, ...)
LRESULT ShowGraphic(HRGN hRgn, HDC hDC, LPCTSTR Format = NULL, ...)
LRESULT ShowGraphic(Gdiplus::Image Image, LPCTSTR Format = NULL, ...)
API返回值(API Return Values)
所有这些错误返回码都在(All these error return codes are defined in the)**WinError.h(WinError.h)**头文件.如果未激活Image Viewer实用程序(请参见上文),则所有(header file. If the Image Viewer utility is not activated (see above) all the) Show*
函数将返回零.如果Image Viewer实用程序处于活动状态,则这些是由(functions will return zero. If the Image Viewer utility is active then these are the possible values returned by the) Show*
功能.(functions.)
-
ERROR_SUCCESS
- 图形对象已成功发送到Image Viewer应用程序.(The graphic object has successfully been sent to the Image Viewer application.)
-
ERROR_NOT_READY
- 用于与Image Viewer应用程序通信的隐藏窗口尚未准备好.最常见的原因是Image Viewer应用程序未运行.(The hidden windows used to communicate with the Image Viewer application are not ready. The most common reason is that the Image Viewer application is not running.)
-
ERROR_INVALID_HANDLE
- 图形对象句柄为NULL.(The graphic object handle is NULL.)
-
ERROR_INVALID_DATA
HRGN
仅对象.的(objects only. The)HRGN
handle有效,但区域本身为空.(handle is valid but the region itself is empty.)
-
ERROR_FUNCTION_FAILED
- 函数内发生未指定的错误,因此无法将图形对象发送到Image Viewer应用程序.(An unspecified error occured within the function so it was unable to send the graphic object to the Image Viewer application.)
-
ERROR_TIMEOUT
- 该函数尝试将图形对象发送到Image Viewer应用程序,但是Image Viewer应用程序花费了很长时间才能响应.(The function tried to send the graphic object to the Image Viewer application but the Image Viewer application took too long to respond.)
-
ERROR_SHARING_PAUSED
- Image Viewer应用程序处于暂停状态,此时未接收任何内容(The Image Viewer application is in the paused state and is not recieving anything at this time)
-
ERROR_NOT_ENOUGH_MEMORY
- Image Viewer应用程序已用完所有分配的内存(The Image Viewer application has used up all it’s alloted memory)
如果您运行提供的演示应用程序,则需要启动(If you run the demo application provided, you will want to start up the)**图像查看器(ImageViewer.exe)**程序,然后逐步执行(program, and then step through the) ViewerDemoView::OnDraw()
功能.(function.)
我希望你们中的一些人像我一样有用.(I hope some of you find this as useful as I do.)
浏览Image Viewer应用程序(Navigating the Image Viewer application)
查看器应用程序在2.0版中已得到极大改进.添加的主要功能是历史记录功能以及将会话或单个图像保存到磁盘以供以后浏览或与他人共享的功能.使用历史记录功能,可以向前和向后浏览生成的图像,从而可以查看和查看它们,而不必重新运行正在调试的应用程序. Image Viewer应用程序被构建为MFC MDI应用程序.每次调试新的应用程序实例时,都会在Image Viewer中创建一个新的MDI文档.这样可以轻松地将一次运行与另一个运行进行比较.还可以创建同一文档的多个视图,因此可以并排比较连续图像.(The viewer application has been greatly improved in version 2.0. The main features added are the history feature and the ability to save the session or individual images to disk for later browsing or sharing with others. With the history feature, it is possible to browse forward and backwards through the images generated so they can be viewed and reviewed without having to rerun the app being debugged. The Image Viewer application is built as an MFC MDI app. Each time a new instance of an app is being debugged, a new MDI document is created in the Image Viewer. This makes it easy to compare one run to another. It is also possible to create multiple views of the same document, so one can compare sequential images side by side.)
也可以将生成的图像保存到磁盘.整个历史文档可以保存到(It is also possible to save the generated images to disk. An entire history document can be saved into a)*** .ivd(**.ivd*)**文件((*file (*)一世(*I*)法师(*mage*)V(*V*)wer(*iewer*)d(*D*)ata文件),可以将其重新加载到Image Viewer中以供以后查看.或者可以将单个图像保存到光盘上的图片文件中.(*ata file) that can be reloaded into the Image Viewer for later viewing. Or individual images can be saved to a picture file on disc.*)
支持的图片文件格式为:(The supported picture file formats are:)
-
便携式网络图形((Portable Network Graphics ()*** .png(**.png*)**).(*).*)
-
Windows位图((Windows Bitmap ()*** .bmp(**.bmp*)**).(*).*)
-
标签图像文件格式((Tag Image File Format ()*** .tiff(**.tiff*)**).(*).*)
-
图形交换格式((Graphics Interchange Format ()*** .gif(**.gif*)**).(*).*)
-
联合摄影专家组((Joint Photographic Experts Group ()*** .jpeg(**.jpeg*)**).(*).*) 此外,Image Viewer可以读取但不能写入以下类型的文件:(*In addition, the Image Viewer can read from, but not write to, the following types of files:*)
-
Windows图标((Windows Icon ()*** .ico(**.ico*)**).(*).*)
- 仅读取第一张图像.不支持多图像图标(Reads the first image only. Does not support multi-image icons)
-
Windows Meta文件((Windows Meta Files ()*** .wmf(**.wmf*)**).(*).*)
-
增强型图元文件((Enhanced Meta Files ()*** .emf(**.emf*)**).(*).*)
工具列(The toolbar)
工具栏上的每个按钮都有一个等效的菜单和一个快捷键.(Every button on the toolbar has a menu equivalent and a keyboard shortcut to go with it.)
图像接收控制(Image reception control)
暂停.(Pause.)
- 菜单:文件/暂停.(Menu: File/Pause.)
- 键盘:<暂停>.(Keyboard: .) 暂停图像接收.图像查看器处于暂停状态时,不会从任何其他应用程序接收任何图像.(Pauses the image reception. The Image Viewer will not receive any images from any other apps while it is in the paused state.)
保存并打开会话数据(Save and Open session data)
保存会话文档.(Save session document.)
- 菜单:文件/另存为.(Menu: File/Save As.)
- 键盘: +‘S’.(Keyboard: +‘S’.) 将整个文档保存到(Saves the entire document to a)*** .ivd(**.ivd*)**文件.如果文件中包含很多图像,该文件可能会变得很大,因为它被保存为一系列未压缩的DIB.(*file. The file can get quite large if there are lots of images in it, as it is saved as a series of uncompressed DIBs.*)
打开会话文档.(Open session document.)
- 菜单:文件/打开.(Menu: File/Open.)
- 键盘: +‘O’.(Keyboard: +‘O’.) 打开一个(Opens an)*** .ivd(**.ivd*)**以前保存的文件.(*file that was previously saved.*)
常规显示选项(General display options)
总在最前面.(Always on Top.)
- 菜单:查看/始终位于顶部.(Menu: View/Always on Top.)
- 键盘:” T".(Keyboard: ‘T’.) 将Image Viewer应用程序保持在所有其他窗口的顶部,这样它就不会被其他进程遮挡.(Keeps the Image Viewer application on top of all other windows so it is never obscured by other processes.)
背景色.(Background Colour.)
- 菜单:查看/背景颜色.(Menu: View/Background Colour.)
- 键盘:" B".(Keyboard: ‘B’.) 弹出标准的"选择颜色"对话框,以选择用于填充图像的透明部分以及填充图像未覆盖的视图部分的背景色.(Brings up the standard Choose Colour dialog to choose the background colour that is used to fill the transparent part of images and also to fill the parts of the views not covered by the images.)
十六进制工具提示.(Hexadecimal Tooltips.)
- 菜单:查看/十六进制工具提示.(Menu: View/Hexadecimal Tooltips.)
- 键盘:" X".(Keyboard: ‘X’.) 在工具提示窗口上的颜色值在十进制和十六进制显示之间切换.(Toggles the colour values on the tooltip window between decimal and hexadecimal display.)
显示锁定.(Display Lock.)
- 菜单:查看/显示锁定.(Menu: View/Display Lock.)
- 键盘:" D".(Keyboard: ‘D’.) 将显示锁定在当前正在查看的图像上.如果未设置此选项,则图像查看器接收到的最后一张图像将在接收时显示.(Locks the display on the image currently being viewed. If this option is not set, the last image received by the Image Viewer is displayed as it is received.)
单张图片选项(Single image options)
另存为图片.(Save as Picture.)
- 菜单:图像/另存为图片.(Menu: Image/Save as Picture.)
- 键盘:" S".(Keyboard: ‘S’.) 将当前正在查看的图像另存为图片文件.(Saves the image currently being viewed on disk as a picture file.)
属性.(Properties.)
- 菜单:图像/属性.(Menu: Image/Properties.)
- 键盘:显示" P",隐藏.(Keyboard: ‘P’ to show, to hide.) 切换属性对话框. “属性"对话框中显示的数据随着当前正在查看的图像更改而更新.(Toggles the Properties dialog. The data displayed on the Properties dialog is updated as the image currently being viewed changes.)
删除图像.(Delete Images.)
- 菜单:图像/删除.(Menu: Image/Delete.)
- 键盘:.(Keyboard: .) 出现一个对话框,在该对话框中可以选择从会话文档中的图像中删除图像或一系列图像.默认设置是删除当前正在查看的图像.(Brings up a dialog where the choice can be made to remove an image or a series of images from the images in the session document. The default setting is to remove the image currently being viewed.)
图像历史选择选项(Image history selection options)
转到第一个图像.(Go to first image.)
-
菜单:图像/第一.(Menu: Image/First.)
-
键盘:Shift +'<'.(Keyboard: Shift + ‘<’.)
-
鼠标:按鼠标右键,然后向上移动鼠标.(Mouse: Press right mouse button, then move mouse up.) 转到上一张图片.(Go to previous image.)
-
菜单:图像/上一个.(Menu: Image/Previous.)
-
键盘:” <".(Keyboard: ‘<’.)
-
鼠标:按鼠标右键,然后向左移动鼠标.(Mouse: Press right mouse button, then move mouse left.) 选择一个图像.(Select an image.)
-
菜单:图像/选择.(Menu: Image/Select.)
-
键盘:"?".(Keyboard: ‘?’.) 转到下一张图像.(Go to next image.)
-
菜单:图像/下一步.(Menu: Image/Next.)
-
键盘:">".(Keyboard: ‘>’.)
-
鼠标:按鼠标右键,然后向右移动鼠标.(Mouse: Press right mouse button, then move mouse right.) 转到最后一张图片.(Go to last image.)
-
菜单:图像/最后一个.(Menu: Image/Last.)
-
键盘:Shift +'>'.(Keyboard: Shift + ‘>’.)
-
鼠标:按鼠标右键,然后向下移动鼠标.(Mouse: Press right mouse button, then move mouse down.)
图像缩放选项(Image zoom options)
显示网格.(Show Grid.)
- 菜单:缩放/网格.(Menu: Zoom/Grid.)
- 键盘:" G".(Keyboard: ‘G’.) 在图像上绘制网格以概述每个像素.图像必须至少放大200%才能显示网格.(Draws a grid on the image that outlines each pixel. The image has to be magnified at least 200% for the grid to show.)
放大.(Zoom In.)
-
菜单:放大/放大.(Menu: Zoom/Zoom In.)
-
键盘:" +".(Keyboard: ‘+’.)
-
鼠标: +向上滚动鼠标滚轮.(Mouse: +Roll mouse wheel up.) 缩小.(Zoom Out.)
-
菜单:放大/缩小.(Menu: Zoom/Zoom Out.)
-
键盘:"-".(Keyboard: ‘-’.)
-
鼠标: +向下滚动鼠标滚轮.(Mouse: +Roll mouse wheel down.)
工具提示和滚动(The tooltip and scrolling)
鼠标光标下方像素的坐标和RGB颜色显示在跟随鼠标光标的工具提示上.控制工具提示最明显的方法是抓住鼠标并移动它.但是对于更好的控制或对于不喜欢使用鼠标的用户,可以使用键盘上的箭头键控制鼠标光标.箭头键的默认行为是首先将图像滚动一个像素,然后将鼠标光标停留在屏幕上,直到无法再滚动图像为止.届时,鼠标光标将移动,直到其到达视图边缘为止.要禁用滚动并改为移动鼠标光标,只需在按住箭头键的同时按住SHIFT键,或切换键盘上的"滚动锁定"按钮即可.为了使此功能起作用,鼠标光标必须位于视图上方,但是只要按键盘上的" C"键,鼠标光标就会在视图上方居中.(The coordinates and the RGB colour of the pixel under the mouse cursor is displayed on a tooltip that follows the mouse cursor around. The most obvious way of controlling the tooltip is to grab the mouse and move it. But for finer control, or for those who do not like using the mouse, the mouse cursor can be controlled with the arrow keys on the keyboard. The default behaviour of the arrow keys is to first scroll the image by one pixel, leaving the mouse cursor where it is on the screen, until the image can not be scrolled any farther. At that point, the mouse cursor will move until it hits the edge of the view. To disable the scrolling and have the mouse cursor move instead, simply hold down the SHIFT key while pressing the arrow keys, or toggle the Scroll Lock button on the keyboard. The mouse cursor has to be over the view in order for this to work, but simply pressing the ‘C’ key on the keyboard will center the mouse cursor over the view.)
也可以使用Home,End,PageUp或PageDown按钮以及滚动鼠标滚轮来滚动视图.这些控件的标准行为是垂直滚动视图,但是在使用这些控件的同时按住SHIFT键,视图将水平滚动.如果正在使用鼠标,则可以通过按住鼠标左键并在视图边缘上移动鼠标光标来滚动视图.单击鼠标中键或鼠标滚轮将启动平移功能.(The view can also be scrolled using the Home, End, PageUp, or PageDown buttons, as well as by rolling the mouse wheel. The standard behaviour of these controls is to scroll the view vertically, but by holding down the SHIFT key at the same time as using these controls, the view will scroll horizontally. If the mouse is being used, the view can be scrolled by holding down the left mouse button and moving the mouse cursor against an edge of the view. Clicking the middle mouse button, or mouse wheel, will start the panning feature.)
内存管理(Memory management)
在下面的论坛中,有人对Image Viewer是真正的内存猪感到担忧.因此,从2.1版开始,现在可以限制查看器可以用来存储接收到的图像的最大内存量.如果没有子视图窗口,则默认菜单将带有选项" Setup/Memory …".如果选择该选项,将出现一个对话框,允许您设置Image Viewer将使用的最大内存量.您可以设置100000 KB到1750000 KB之间的任何数量.(There was some concern expressed in the forums below about the Image Viewer being a real memory hog. So as of version 2.1 it now possible to limit the maximum amount of memory that the viewer can use to store the images it receives. When there are no child view windows open the default menu will have an option “Setup/Memory…”. If you select that option you will get a dialog that allows you to set the maximum amount of memory that the Image Viewer will use. You can set any amount in the range of 100000 KB through to 1750000 KB.)
控制内存使用的另一种机制是添加了"暂停"命令和工具栏按钮.现在可以暂停Image Viewer应用程序,这样它就不会从任何其他尝试发送图像的应用程序中接收图像.(Another mechanism that was added to control memory usage was the addition of the “Pause” command and toolbar button. It is now possible to pause the Image Viewer application so it will not receive images from any other applications that may be trying to send them.)
为了使用户能够在任何给定时间查看Image Viewer应用程序正在使用多少内存,已将内存使用情况计量器添加到状态栏中.仪表具有使用中的内存量的文本读数,并且具有图形化的"进度条",该进度条显示了已使用的可用内存量以及仍然可用的内存量(In order for the user to able to see how much memory that Image Viewer application is using at any given time a memory usage meter has been added to the status bar. The meter has a textual readout of the amount of memory being used, and it has a graphical “progress bar” that shows how much of the available memory is used and how much is still available)
内存使用率表(Memory usage meter)
要在内存不足时释放内存,只需关闭文档窗口或使用"图像/删除"命令删除一堆您可能不再需要的较旧图像即可.(To free up memory when you run low it is simply a matter of either closing a document window, or using the “Image/Delete” command to delete a bunch of the older images that you may not need anymore.)
状态栏(Status Bars)
状态栏可用于提供有关Image Viewer应用程序和当前正在查看的图像的信息.主要状态栏包含三个窗格.第一个是标准信息窗格,该窗格显示应用程序的当前状态,并显示有关当前选择的工具栏按钮和菜单项的有用提示.第二个是前面提到的内存使用量表.第三个是滚动锁定指示器.(The status bars can be used to give information about the Image Viewer application and about the image currently being viewed. The main status bar has three panes. The first is the standard information pane that shows the current status of the application and also displays helpful hints about the toolbar buttons and menu items that are currently selected. The second is the memory usage meter mentioned previously. The third is the Scroll lock indicator.)
附加在子视图窗口上的状态栏显示有关该视图中当前显示的图像的信息.它有六个窗格,可以通过在"视图/指示器"菜单中选择它们来选择显示或隐藏.第一个窗格是"文本"窗格.它显示了图像附带的文本的第一行.(The status bar that is attached to the child view windows shows information about the image currently being displayed in that view. It has six panes that can be optionally shown or hidden by selecting them in the View/Indicators menu. The first pane is the Text pane. It shows the first line of the text that is supplied with the image when the) Show*
函数被调用.接下来的窗格显示时间(functions are called. The next panes show the time the) Show*
函数被调用,源文件,行和函数位于(function was called and the source file, line, and function where the) Show*
功能位于.最后一个窗格显示图像的大小(以像素为单位).(function is located. The last pane shows the size, in pixels, of the image.)
图像查看器的状态栏(The Image Viewer’s status bars)
愿望清单(Wish list)
我想在此应用程序中添加几件事.主要的是扩展对GDI + API的支持.目前只(There are several things I would like to add to this application. The main one is to expand the support for the GDI+ API. Currently only) Gdiplus::Image
支持.我还想添加对其余GDI对象的支持,例如(is supported. I would also like to add support for the rest of the GDI objects, such as) HPEN
,(,) HBRUSH
, 和别的.我还想编写一个安装程序/卸载程序,该程序将正确设置并使用各种版本的Visual Studio注册文件.(, and others. I would also like to write an installer/uninstaller that will properly setup and register the files with the various versions of Visual Studio.)
如果您确实决定为此应用程序实现任何其他功能,请随时在下面的论坛中发布代码,或通过电子邮件将其发送给我.如果我喜欢它们,甚至可以在将来的版本中包括它们.(If you do decide to implement any additional features to/for this application feel free to post the code in the forum below, or send them to me via email. If I like them I may even include them in future versions.)
免责声明(Disclaimer)
PJ Arends版权所有(c)2001-2006(Copyright (c) 2001-2006, PJ Arends)
该软件以FREEWARE的形式发布,按"原样"提供,没有任何明示或暗示的保证,包括但不限于针对特定目的的适销性和适用性的暗示保证.(This software is released as FREEWARE and is provided “AS-IS” without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose.)
可以按您希望的任何方式使用此代码.只要不以牟利为目的,可以通过任何方式重新分发此代码,并提供此通知和作者的姓名.原始作者未进行的任何修改都应明确标明,以消除原始版本与任何其他版本之间的混淆.(This code may be used in any way you desire. This code 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.)
感谢和感谢(Thanks and Credits)
- 于尔根`西格瓦德森(Jurgen Sigvardsson)(Jrgen Sigvardsson) 用于提供代码以显示图像列表.(for supplying the code to display image lists.)
- 沃尔德`莫特(WalderMort) 用于向显示区域提供代码.(for supplying the code to display regions.)
- Mor FTP(Mor FTP) 用于提供原始代码(for supplying the original code for the)
ShowGraphic()
功能和其他功能的想法.(function and ideas for other features.) - 丹妮
坎汀(*Dany Cantin*)](http://www.codeproject.com/script/profile/whos_who.asp?id=16796) 为了(*for the*) [
CTrueColorToolBar` 类.(class.) - [保罗
墨西拿(*Paolo Messina*)](http://www.codeproject.com/script/profile/whos_who.asp?id=168) 为了(*for the*) [可调整大小的库(*ResizableLib*)](http://www.codeproject.com/dialog/resizablelib.asp) 我从中抓取的文章(*article from which I grabbed the*)
CResizableGrip` 类.(class.) - 克里斯
梅德(*Chris Maunder*)](http://www.codeproject.com/script/profile/whos_who.asp?id=1) 和(*and*) [汉斯
迪特里希(Hans Dietrich) 为了(for the)CXHyperLink
“关于"框中使用的类.(class that is used in the About box.) - John Simmons/非法程序员(John Simmons / outlaw programmer) 为了(for the) 理想文字颜色(Ideal Text Color) 文章.(article.)
- 詹姆士`约翰逊(James T. Johnson) 为了(for the) 影像旋转(Image Rotation) 文章.(article.)
- 阿什莉
范
格文(Ashley van Gerven) 用于为工具栏按钮提供一些插图.(for supplying some of the artwork for the toolbar buttons.) - 安德鲁`和平(Andrew Peace) 为了(for the) HTML目录生成器(HTML Table Of Contents Generator) 我曾经为本文制作TOC.(that I used to make the TOC for this article.)
更新(Updates)
-
2002年1月31日(January 31, 2002)
- 修复了Melwyn报告的W2K错误.(Fixed W2K bug reported by Melwyn.)
-
2004年4月11日(April 11, 2004)
- 添加了(Added the)
ShowIcon()
功能.(function.)
- 添加了(Added the)
-
2004年8月31日(August 31, 2004)
- 添加了(Added the)
ShowGDIPlusBitmap()
功能.(function.) - 添加了(Added the)
ShowImageList()
功能. (感谢Jrgen)(function. (Thanks Jrgen))
- 添加了(Added the)
-
2006年9月12日(September 12, 2006)
- 发布了2.0版.(Released version 2.0.)
-
2006年11月13日-版本2.1(November 13, 2006 - Version 2.1)
- 添加了(Added the)
ShowRegion
功能. (感谢WalderMort)(functions. (Thanks WalderMort)) - 添加了内存管理和暂停功能.(Added the memory management and pause features.)
- 各种其他代码清除和增强.(Various other code cleanups and enhancements.)
- 添加了(Added the)
-
2006年12月16日-2.2版(December 16, 2006 - Version 2.2)
- 添加了(Added the)
ShowFont
功能.(function.) - 添加了(Added the)
ShowGraphic
功能. (感谢Mor FTP.)(function. (Thanks Mor FTP.)) - 更新了图像查看器的子状态栏.现在可以选择显示有关当前图像的更多信息.(Updated the Image Viewer’s child status bar. Now has the option to show more information about the current image.)
- 更新了图像查看器处理区域的方式.工具提示现在显示区域的坐标,并且区域边界矩形的坐标现在显示在状态栏上.(Updated how the Image Viewer handles regions. The tooltip now shows the region’s coordinates, and the coordinates of the region’s bounding rectangle is now displayed on the status bar.)
- 将错误返回码添加到了(Added the error return codes to the)
Show*
功能.(functions.) - 更改了"转到第一个图像"和"转到最后一个图像"命令的键盘快捷键.(Changed the keyboard shortcuts for the “Goto First Image” and “Goto Last Image” commands.)
- 在文章文本中添加了愿望清单和免责声明.(Added the wish list and disclaimer to the article text.)
- 添加了(Added the)
-
2006年12月23日-版本2.2.1(December 23, 2006 - Version 2.2.1)
- 修复了Owen Lawrence报告的错误.(Fixed bug reported by Owen Lawrence.)
-
2006年3月5日-版本2.3(March 5, 2006 - version 2.3)
- 添加了对直接加载某些图形文件的支持.现在可以将Image Viewer应用程序用作独立的图片查看应用程序.(Added support for directly loading certain graphics files. The Image Viewer Application can now be used a stand alone picture viewing application.)
- 重写了绘图代码,因此我们现在可以放大大型图像而不会耗尽系统资源.(Rewrote the drawing code so we can now zoom in on large images without running out of system resources.)
- 在文章中添加了目录.(Added a table of contents to the article.)
- 各种其他小的修复和调整(Various other minor fixes and tweaks)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ VC8.0 WinXP Windows Win2K Visual-Studio Dev 新闻 翻译