Displaying Images Using imgdecmp.dll and VOImage
Environment: WinCE 3.0 \ Pocket PC 2002 : MVCE 3.0 PPC 2002 SDK: MCF
Display images using imgdecmp.dll and modifed VOImage wrapper class. ( I took the liberty of making CVOImage::g_iScale public -> I should keep this private and create set\get (limited time).)
This shows how to use Pocket PCs IMGDECMP.dll image processor through the free CVOImage class libraries. Using embeded Visual C++ and the Pocket PC 2002 SDK (MFC) I have created a simple image viewer which loads graphics files from disk. Tested on iPaq 3850.
The program looks for files in \My Documents\album\ and adds them to a combobox. The image is displayed when clicked ( or scrolled to ) in the combo box. You should create a folder named 'album' under 'My Documents' and put any images you would like to view in there.
See http://www.microsoft.com/mobile/developer/technicalarticles/graphics.asp to display images loaded as resources.
Using IMGDECMP.dll
Microsoft uses the IMGDECMP DLL in Microsoft Internet Explorer for the Pocket PC to display JPEG, GIF, BMP, PNG, and other standard graphics file formats. There are several reasons for using the IMGDECMP DLL to decode the graphics in your own applications:
- By using a common component such as the IMGDECMP DLL, you reduce the memory footprint of your application.
- You will not be shipping the decoding code with your product, so you can avoid licensing patented code, such as the GIF format, which is owned by CompuServe and normally requires a licensing royalty.
- Performance is very good.
- The code has been tested thoroughly and is very stable.
- You can code directly to the IMGDECMP DLL if you wish. Conduits Technologies has an excellent Web site dedicated to this.
BOOL CImageDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does
// this automatically when the application's main
// window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the
// hpc screen
CVOImage image;
RECT pic_rect;
m_picture_window.GetWindowRect(&pic_rect);
_WIN32_FIND_DATAW *FindFileDataStruct =
new _WIN32_FIND_DATAW;
HDC picDC = ::GetDC(m_picture_window.m_hWnd );
//
// find all the files in '\My Documents\album\' and
// put them in the list
//
HANDLE search_handle =
::FindFirstFile((LPCTSTR)_T("\\My Documents\\album\\*.*"),
FindFileDataStruct);
if( search_handle == INVALID_HANDLE_VALUE )
{
m_combo1.AddString( (LPCTSTR) _T("No Files Found"));
}else{
m_combo1.AddString((LPCTSTR) FindFileDataStruct->cFileName);
}
while(::FindNextFile(search_handle, FindFileDataStruct) != 0 )
{
m_combo1.AddString((LPCTSTR) FindFileDataStruct->cFileName);
}
//
// Show first in list
//
m_combo1.SetCurSel(0);
//
// close the search handle and clean up
//
::FindClose ( search_handle);
delete FindFileDataStruct;
//
// Set the slider range
//
m_scale.SetRange(1,10);
m_scale.SetPos(10);
return TRUE; // return TRUE unless you set the
// focus to a control
}
void CImageDlg::OnSelchangeCombo1()
{
CVOImage image;
RECT pic_rect;
m_picture_window.GetWindowRect(&pic_rect);
HDC picDC = ::GetDC(m_picture_window.m_hWnd );
//
// Show the selected picture
//
CString path = _T("\\My Documents\\album\\");
CString image_name = "";
m_combo1.GetLBText( m_combo1.GetCurSel(), image_name);
CString path_fname = path + image_name;
//
// Load the image
//
image.Load (picDC ,path_fname );
if( this->m_stretch_image.GetCheck() == BST_CHECKED)
{
//
// If you want to maintain the aspect ratio then
// modify this!
//
image.Draw (picDC,
10,
10,
pic_rect.bottom - pic_rect.top,
pic_rect.right - pic_rect.left - 10);
}else{
image.Draw (picDC ,10,10 );
}
//
// Release the DC;
//
::ReleaseDC( m_picture_window.m_hWnd, picDC);
}
void CImageDlg::OnCheckStretch()
{
CVOImage image;
RECT pic_rect;
m_picture_window.GetWindowRect(&pic_rect);
HDC picDC = ::GetDC(m_picture_window.m_hWnd );
//
// Show the selected picture
//
CString path = _T("\\My Documents\\album\\");
CString image_name = "";
m_combo1.GetLBText( m_combo1.GetCurSel(), image_name);
CString path_fname = path + image_name;
// m_picture_window.SetWindowText(image_name);
image.Load (picDC ,path_fname );
if( this->m_stretch_image.GetCheck() == BST_CHECKED)
{
image.Draw (picDC,
10,
10,
pic_rect.bottom - pic_rect.top,
pic_rect.right - pic_rect.left - 10 );
}else{
image.Draw (picDC ,10,10 );
}
//
// Releae the DC;
//
::ReleaseDC( m_picture_window.m_hWnd, picDC);
}
void CImageDlg::OnHScroll(UINT nSBCode,
UINT nPos,
CScrollBar* pScrollBar)
{
//
// Set the scale and re display the picture.
//
if( pScrollBar->m_hWnd == this->m_scale.m_hWnd) // Ensure the
// correct scroll bar
{
int curpos = this->m_scale.GetPos();
int cur_scale = (int) curpos * 10;
//
// Made CVOImage::g_iScale public -> I should keep private
// and create set\get (limited time).
// Set the scale on
CVOImage::g_iScale = cur_scale;
char s_scale[16];
sprintf(s_scale, "%d", cur_scale);
m_edit_scale.SetWindowText((CString)s_scale);
CVOImage image;
RECT pic_rect;
//
// The display window RECT
//
m_picture_window.GetWindowRect(&pic_rect);
//
// The HDC of the display window
//
HDC picDC = ::GetDC(m_picture_window.m_hWnd );
//
// Show the selected picture
//
CString path = _T("\\My Documents\\album\\");
CString image_name = "";
m_combo1.GetLBText( m_combo1.GetCurSel(), image_name);
CString path_fname = path + image_name;
image.Load (picDC ,path_fname );
if( this->m_stretch_image.GetCheck() == BST_CHECKED)
{
image.Draw (picDC,
10,
10,
pic_rect.bottom - pic_rect.top,
pic_rect.right - pic_rect.left - 10);
}else{
image.Draw (picDC ,10,10 );
}
//
// Releae the DC;
//
::ReleaseDC( m_picture_window.m_hWnd, picDC);
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
Downloads
Download demo project - 143 KbDownload source - 13 Kb

Comments
More concessions with herveleger, more steal also gaolbird napping!
Posted by jckmrcobfj on 04/29/2013 09:17pmgirlfriendpast one's prime crumpetbe in be at one withpick uppolehawk
ReplyNo file found
Posted by smartslack on 12/14/2005 07:41amDownload demo project and download sourc link dosen't work..? giving no file found message.. ?? smartslack
Replyhow about for animated gif?
Posted by Cassie Tsui on 03/07/2005 11:28amcan i use the same method to view an animated gif? or other suggestions? please help, thank you!!
ReplyIMGDECMP dll file, h file ...location on web...
Posted by BobBoots on 12/16/2004 08:29amI found this article very helpful since I could not otherwise find a way to put such a wide variety of images on the display of a CE device. So after a bit of hunting...I found this website with the IMGDECMP .dll and .h file as well as a detailed explaination showing it's use. http://www.unsupportedsoftware.com/ce/dev/imgdecmp.htm ~Bob
ReplyIMGDECMP on .NET
Posted by rbdizon on 11/25/2004 04:59amI there a way that I can use IMGDECMP.DLL on VB.NET or C#? If so, how?
-
Replyimgdecmp.dll
Posted by david_wxl2005 on 09/22/2006 03:32amimgdecmp.dll
Replyasking help for BMP viewer in HPC 2000
Posted by Legacy on 01/15/2004 12:00amOriginally posted by: vincent sim
hi everybody
I am doing one programming for displaying BMP picture in windows CE handheld PC 2000. I met a lot of problems in developing the bmp viewer in HPC 2000. I wonder whether anybody have some related BMP viewer source codes for the environment : win CE 3.0\ Handheld PC 2000 . I hope I could have your kindly guidance.
thank you very much.
have a nice day.
ReplyIcon resizing
Posted by Legacy on 01/09/2004 12:00amOriginally posted by: Jen
ReplyQ: How can I use the "DecompressImageInfo" structure with
Posted by Legacy on 07/31/2003 12:00amOriginally posted by: henry
Replybitmap not released?
Posted by Legacy on 07/18/2003 12:00amOriginally posted by: Harold Price
ReplyHelp needed...
Posted by Legacy on 05/11/2003 12:00amOriginally posted by: Viona
Is it possible to scribble or write on the .jpg image? I have no idea on how to go about doing it.
ReplyAny help will be greatly appreciated.
Thanks
Loading, Please Wait ...