YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   Home Products | Purchase Support | Downloads  
View in English
View in Japanese
View in
참고
View in Français
View in Italiano
View in 中文(繁體)
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Overview
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
Purchase
VX++ Cross-Platform C/C++
Overview
Download
Purchase
ActiveX COM Products
Overview
Download
Purchase
Technical Support
  General Q & A
Discussion Board
Contact Us

Links

Get Ready to Unleash the Power of UCanCode .NET

CXImage Library, PNG, Show, Pocket PC with VC++ Sample

 

Details

Most of the work was in taking the original CXImage library and modifying it to make it compile on the PocketPC (Using eVC 3.0) This required a few #define changes and #ifdef out any try...catch code. I opted to return false.

The next step was debugging the PNG code. Since the PNG library uses function pointers, it turns out that eVC modifies the signature between a debug and release build. The stack becomes corrupt upon return unless the signature for these functions are modified as below:

#if defined (_WIN32_WCE) && !defined (_DEBUG)
	#define _CDECL_MODE_	__cdecl
#else
	#define _CDECL_MODE_	
#endif

static void _CDECL_MODE_ user_write_data(png_structp png_ptr, 
                                         png_bytep data, 
                                         png_size_t length)
Finally, I modified DibSectionLite to include:
  • All the suggested fixes posted on UCanCode (including 16, 24 bit images)
  • Cropping. I have a floorplan image I need to pan around on the screen, cropping is quite fast when displaying only a portion of the image.
  • Original Load and Save now take a CFile or CString.. Useful for memory images (CMemFile)
  • Loading images via CXImage.

You can add support and shrink/expand you executable size based on these defines as well as the ones in CXImage:

#define DIBSECTION_SUPPORT_BMP 1
#define DIBSECTION_SUPPORT_GIF 1    // Patented! 
#define DIBSECTION_SUPPORT_JPG 1
#define DIBSECTION_SUPPORT_PNG 1
//#define DIBSECTION_SUPPORT_MNG 0  // Orig. Lib disabled this
#define DIBSECTION_SUPPORT_ICO 1
//#define DIBSECTION_SUPPORT_TIF 0  // Patented!   //too many problems with 
                                    // __cdecl, see header  //jk
#define DIBSECTION_SUPPORT_TGA 1
#define DIBSECTION_SUPPORT_PCX 1
//#define DIBSECTION_SUPPORT_WBMP 0 //totally corrupt image... This might 
                                    // take some work.  //jk 
//#define DIBSECTION_SUPPORT_WMF 0  // WMF and PocketPC don't go hand-in hand 
                                    // too well (GetEnhMetaFilePaletteEntries 
                                    // unsupported by the OS).
//#define DIBSECTION_SUPPORT_J2K 0  // Beta  //totally corrupt image... This 
                                    //might take some work. //jk
#define DIBSECTION_SUPPORT_JBG 1    // Patented! see ../jbig/patents.htm    

New methods for loading are as follows:
BOOL LoadPNG(LPCTSTR lpszFileName);
BOOL LoadJPG(LPCTSTR lpszFileName);
BOOL LoadBMP(LPCTSTR lpszFileName);
BOOL LoadGIF(LPCTSTR lpszFileName);
BOOL LoadMNG(LPCTSTR lpszFileName);
BOOL LoadICO(LPCTSTR lpszFileName);
BOOL LoadTIF(LPCTSTR lpszFileName);
BOOL LoadTGA(LPCTSTR lpszFileName);
BOOL LoadPCX(LPCTSTR lpszFileName);
BOOL LoadWBMP(LPCTSTR lpszFileName);
BOOL LoadWMF(LPCTSTR lpszFileName);
BOOL LoadJ2K(LPCTSTR lpszFileName);
BOOL LoadJBG(LPCTSTR lpszFileName);
The code unravels and builds as a bunch of .LIB

You can compile and build the PocketPCTest app for your device. It is nothing fancy. Simply an exerciser. Uncomment the line in PocketPCTestView.cpp as needed.

The test app includes a definition of:

CDIBSectionLite	m_image;
in the header.

To Draw:

void CPocketPCTestView::OnDraw(CDC* pDC)
{
	CPocketPCTestDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	// TODO: add draw code for native data here
	
	m_image.Draw(pDC, CPoint(0,0));

}
And to load:
CPocketPCTestView::CPocketPCTestView()
{ 
	// TODO: add construction code here

	m_image.LoadPNG(_T("\\test.png"));	// 24bit OK
//	m_image.LoadPNG(_T("\\test-pal.png"));	// 256 OK
//	m_image.LoadJPG(_T("\\test.JPG"));	//ok
//	m_image.LoadBMP(_T("\\test.BMP"));	//ok
//	m_image.LoadGIF(_T("\\test.GIF"));	//ok
//	m_image.LoadICO(_T("\\test.ICO"));	//ok
//	m_image.LoadTGA(_T("\\test.TGA"));	//ok
//	m_image.LoadPCX(_T("\\test.PCX"));	//ok
//	m_image.LoadJBG(_T("\\test.JBG"));	//ok
	
// This wasn't in the original code.
////	m_image.LoadMNG(_T("\\test.MNG"));	

// WMF and PocketPC don't go hand-in hand too well (GetEnhMetaFilePaletteEntries 
// unsupported by the OS).
////	m_image.LoadWMF(_T("\\test.WMF"));	

// too many problems with __cdecl, see header
////	m_image.LoadTIF(_T("\\test.TIF"));	

// totally corrupt image... This might take some work.
////	m_image.LoadWBMP(_T("\\test.WBMP"));

// totally corrupt image... This might take some work.
////	m_image.LoadJ2K(_T("\\test.J2K"));	

}
That's about it. I didn't really spend much time with making J2K, TIF, and WBMP work. I'll update the article if someone gets them working.
 

News:

1 UCanCode Advance E-XD++ CAD Drawing and Printing Solution Source Code Solution for C/C++, .NET V2024 is released!

2 UCanCode Advance E-XD++ HMI & SCADA Source Code Solution for C/C++, .NET V2024 is released!

3 UCanCode Advance E-XD++ GIS SVG Drawing and Printing Solution Source Code Solution for C/C++, .NET V2024 is released!


Contact UCanCode Software

To buy the source code or learn more about with:

 

Ask any questions by MSN: UCanCode@hotmail.com Yahoo: ucan_code@yahoo.com


 

Copyright ?1998-2024 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@UCanCode.net