How to display JPEG files?

How to display JPEG files?

Post by Denni » Wed, 04 Dec 2002 16:45:55



Recently, in this group, I saw a question asked about displaying JPEG files.
There were two answers.   One from "Perpetual Projects" said to include
"imgdecmp.h" and gave some sample code.   The other, from "Ron Craswell"
suggested using a free wrapper class (from
http://www.voscorp.com/asp/PPC/Dev/VOImage/default.asp) which wraps the
imgdecmp.dll.

"Perpetual Projects"s example looked to me as if it was chopped and only
part of the example was present.   I've written him to see if I can get the
full listing.

In the mean time, does anyone else have any example code for displaying
JPEGs on a PPC?   Or maybe a reference to a discussion on how to use the
four APIs I see exposed in the imgdecmp.h file?

Anyone have any experiences good or bad with the wrapper class Ron Craswell
suggested?

Many thanks!

--
Dennis
Woods Creek Wholesale Nursery
Monroe, WA

 
 
 

How to display JPEG files?

Post by devr » Thu, 05 Dec 2002 03:16:09


Im using imgdecmp to load jpegs right now. It works but seems to have a bug
where I cannot load COM/ActiveX objects after I have used it.... ? I am also
using libjpeg (free) for saving jpegs, so I will probably swtich to that for
loading also. Heres some code I ripped and modifed from the imgdecomp
samples. HTH

// Initialize. ResetsObj()!
// (RETURNS: 0 on failure)
int BmpImageLoader::Init(){

 ResetObj();           // Reset

 // Load dll & procedure address if not loaded. Do it once (ResetObj() does
not
 // ..unload the dll in other words. There is no reason to)
 if ( !hDeCmpDLL ){
  hDeCmpDLL = LoadLibrary( _T("imgdecmp.dll") );
  if ( !hDeCmpDLL )
   return 0;
 }

 if ( !DLLImageLoad ){
  DLLImageLoad = (HRESULT(*)(DecompressImageInfo
))GetProcAddress( hDeCmpDLL,
   _T("DecompressImageIndirect") );
  if ( !DLLImageLoad )
   return 0;
 }

 return 1;           // success

Quote:}

// Load bitmap.
// (PASS: hdc image will be used with, file name)
// (RETURNS: 0 on failure)
int BmpImageLoader::Load( HDC hdc, LPCTSTR file_name ){

 // we must be initialized to load
 if ( !hDeCmpDLL || !DLLImageLoad )
  return 0;          // failure

 ResetObj();           // reset

 // if file_name is NULL, we are done.
 if ( file_name == NULL )
  return 1;          // success

 // open the file
 HANDLE hfile = CreateFile( file_name, GENERIC_READ, FILE_SHARE_READ, NULL,
  OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );

 if (hfile == INVALID_HANDLE_VALUE)
  return 0;          // failure

 // Fill in the 'DecompressImageInfo' structure
 BYTE    buffer[1024] = {0};
 HBITMAP hbmp = NULL;
 DecompressImageInfo dii;

 dii.dwSize = sizeof( DecompressImageInfo );  // Size of this structure
 dii.pbBuffer = buffer;       // Pointer to the buffer to use for data
 dii.dwBufferMax = 1024;       // Size of the buffer
 dii.dwBufferCurrent = 0;      // The amount of data which is current in the
buffer
 dii.phBM = &hbmp;        // Pointer to the bitmap returned (can be NULL)
 dii.ppImageRender = NULL;      // Pointer to an IImageRender object (can be
NULL)
 dii.iBitDepth = GetDeviceCaps( hdc,BITSPIXEL ); // Bit depth of the output
image
 dii.lParam = ( LPARAM ) hfile;     // User parameter for callback functions
 dii.hdc = hdc;         // HDC to use for retrieving palettes
 dii.iScale = 100;        // Scale factor (1 - 100)
 dii.iMaxWidth = 10000;       // Maximum width of the output image
 dii.iMaxHeight = 10000;       // Maxumum height of the output image
 dii.pfnGetData = DeCmp_GetData;     // Callback function to get image data
 dii.pfnImageProgress = DeCmp_ImageProgress;  // Callback function to notify
caller of progress decoding the image
 dii.crTransparentOverride = ( UINT ) -1;  // If this color is not (UINT)-1,
it will override the
             // transparent color in the image with this color. (GIF ONLY)

 // Process and decompress the image data
 HRESULT hr = DLLImageLoad( &dii );

 // close file
 CloseHandle( hfile );

 // test hr
 if ( FAILED( hr ) )
  return 0;         // failure

 // attach the hbmp
 Bitmap.Attach( hbmp );

 return 1;         // success

Quote:}

// DeCmp dll get image data callback. lparam is a file handle, just read the
file.
DWORD CALLBACK BmpImageLoader::DeCmp_GetData( LPSTR buffer, DWORD
max_buffer,
            LPARAM lparam ){

 DWORD num_red;

 if ( (HANDLE)lparam == INVALID_HANDLE_VALUE )
  return 0;

 ReadFile( (HANDLE)lparam, buffer, max_buffer, &num_red, NULL );

 // Return number of bytes read
 return num_red;

Quote:}

// DeCmp progress callback.
void CALLBACK BmpImageLoader::DeCmp_ImageProgress( IImageRender *prender,
 BOOL bcomplete, LPARAM lparam ){

 if( bcomplete ){
  ;// (Optional) add code here for completion processing
 }

}



Quote:> Recently, in this group, I saw a question asked about displaying JPEG
files.
> There were two answers.   One from "Perpetual Projects" said to include
> "imgdecmp.h" and gave some sample code.   The other, from "Ron Craswell"
> suggested using a free wrapper class (from
> http://www.voscorp.com/asp/PPC/Dev/VOImage/default.asp) which wraps the
> imgdecmp.dll.

> "Perpetual Projects"s example looked to me as if it was chopped and only
> part of the example was present.   I've written him to see if I can get
the
> full listing.

> In the mean time, does anyone else have any example code for displaying
> JPEGs on a PPC?   Or maybe a reference to a discussion on how to use the
> four APIs I see exposed in the imgdecmp.h file?

> Anyone have any experiences good or bad with the wrapper class Ron
Craswell
> suggested?

> Many thanks!

> --
> Dennis
> Woods Creek Wholesale Nursery
> Monroe, WA


 
 
 

How to display JPEG files?

Post by Bernha » Thu, 05 Dec 2002 05:57:17


Hi Dennis,

Have a look here:
http://www.unsupportedsoftware.com/ce/dev/imgdecmp.htm

Regards,
Dennis


> Recently, in this group, I saw a question asked about displaying JPEG files.
> There were two answers.   One from "Perpetual Projects" said to include
> "imgdecmp.h" and gave some sample code.   The other, from "Ron Craswell"
> suggested using a free wrapper class (from
> http://www.voscorp.com/asp/PPC/Dev/VOImage/default.asp) which wraps the
> imgdecmp.dll.

> "Perpetual Projects"s example looked to me as if it was chopped and only
> part of the example was present.   I've written him to see if I can get the
> full listing.

> In the mean time, does anyone else have any example code for displaying
> JPEGs on a PPC?   Or maybe a reference to a discussion on how to use the
> four APIs I see exposed in the imgdecmp.h file?

> Anyone have any experiences good or bad with the wrapper class Ron Craswell
> suggested?

> Many thanks!

 
 
 

How to display JPEG files?

Post by Denni » Thu, 05 Dec 2002 06:11:33


Devr,

Thanks for the source.   I've been looking through it and it looks good.   I
have a question though.   What's ResetObj() do?

Thanks!
--
Dennis
Woods Creek Wholesale Nursery
Monroe, WA


> Im using imgdecmp to load jpegs right now. It works but seems to have a
bug
> where I cannot load COM/ActiveX objects after I have used it.... ? I am
also
> using libjpeg (free) for saving jpegs, so I will probably swtich to that
for
> loading also. Heres some code I ripped and modifed from the imgdecomp
> samples. HTH

> // Initialize. ResetsObj()!
> // (RETURNS: 0 on failure)
> int BmpImageLoader::Init(){

>  ResetObj();           // Reset

>  // Load dll & procedure address if not loaded. Do it once (ResetObj()
does
> not
>  // ..unload the dll in other words. There is no reason to)
>  if ( !hDeCmpDLL ){
>   hDeCmpDLL = LoadLibrary( _T("imgdecmp.dll") );
>   if ( !hDeCmpDLL )
>    return 0;
>  }

>  if ( !DLLImageLoad ){
>   DLLImageLoad = (HRESULT(*)(DecompressImageInfo
> ))GetProcAddress( hDeCmpDLL,
>    _T("DecompressImageIndirect") );
>   if ( !DLLImageLoad )
>    return 0;
>  }

>  return 1;           // success
> }

> // Load bitmap.
> // (PASS: hdc image will be used with, file name)
> // (RETURNS: 0 on failure)
> int BmpImageLoader::Load( HDC hdc, LPCTSTR file_name ){

>  // we must be initialized to load
>  if ( !hDeCmpDLL || !DLLImageLoad )
>   return 0;          // failure

>  ResetObj();           // reset

>  // if file_name is NULL, we are done.
>  if ( file_name == NULL )
>   return 1;          // success

>  // open the file
>  HANDLE hfile = CreateFile( file_name, GENERIC_READ, FILE_SHARE_READ,
NULL,
>   OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );

>  if (hfile == INVALID_HANDLE_VALUE)
>   return 0;          // failure

>  // Fill in the 'DecompressImageInfo' structure
>  BYTE    buffer[1024] = {0};
>  HBITMAP hbmp = NULL;
>  DecompressImageInfo dii;

>  dii.dwSize = sizeof( DecompressImageInfo );  // Size of this structure
>  dii.pbBuffer = buffer;       // Pointer to the buffer to use for data
>  dii.dwBufferMax = 1024;       // Size of the buffer
>  dii.dwBufferCurrent = 0;      // The amount of data which is current in
the
> buffer
>  dii.phBM = &hbmp;        // Pointer to the bitmap returned (can be NULL)
>  dii.ppImageRender = NULL;      // Pointer to an IImageRender object (can
be
> NULL)
>  dii.iBitDepth = GetDeviceCaps( hdc,BITSPIXEL ); // Bit depth of the
output
> image
>  dii.lParam = ( LPARAM ) hfile;     // User parameter for callback
functions
>  dii.hdc = hdc;         // HDC to use for retrieving palettes
>  dii.iScale = 100;        // Scale factor (1 - 100)
>  dii.iMaxWidth = 10000;       // Maximum width of the output image
>  dii.iMaxHeight = 10000;       // Maxumum height of the output image
>  dii.pfnGetData = DeCmp_GetData;     // Callback function to get image
data
>  dii.pfnImageProgress = DeCmp_ImageProgress;  // Callback function to
notify
> caller of progress decoding the image
>  dii.crTransparentOverride = ( UINT ) -1;  // If this color is not
(UINT)-1,
> it will override the
>              // transparent color in the image with this color. (GIF ONLY)

>  // Process and decompress the image data
>  HRESULT hr = DLLImageLoad( &dii );

>  // close file
>  CloseHandle( hfile );

>  // test hr
>  if ( FAILED( hr ) )
>   return 0;         // failure

>  // attach the hbmp
>  Bitmap.Attach( hbmp );

>  return 1;         // success
> }

> // DeCmp dll get image data callback. lparam is a file handle, just read
the
> file.
> DWORD CALLBACK BmpImageLoader::DeCmp_GetData( LPSTR buffer, DWORD
> max_buffer,
>             LPARAM lparam ){

>  DWORD num_red;

>  if ( (HANDLE)lparam == INVALID_HANDLE_VALUE )
>   return 0;

>  ReadFile( (HANDLE)lparam, buffer, max_buffer, &num_red, NULL );

>  // Return number of bytes read
>  return num_red;
> }

> // DeCmp progress callback.
> void CALLBACK BmpImageLoader::DeCmp_ImageProgress( IImageRender *prender,
>  BOOL bcomplete, LPARAM lparam ){

>  if( bcomplete ){
>   ;// (Optional) add code here for completion processing
>  }
> }



> > Recently, in this group, I saw a question asked about displaying JPEG
> files.
> > There were two answers.   One from "Perpetual Projects" said to include
> > "imgdecmp.h" and gave some sample code.   The other, from "Ron Craswell"
> > suggested using a free wrapper class (from
> > http://www.voscorp.com/asp/PPC/Dev/VOImage/default.asp) which wraps the
> > imgdecmp.dll.

> > "Perpetual Projects"s example looked to me as if it was chopped and only
> > part of the example was present.   I've written him to see if I can get
> the
> > full listing.

> > In the mean time, does anyone else have any example code for displaying
> > JPEGs on a PPC?   Or maybe a reference to a discussion on how to use the
> > four APIs I see exposed in the imgdecmp.h file?

> > Anyone have any experiences good or bad with the wrapper class Ron
> Craswell
> > suggested?

> > Many thanks!

> > --
> > Dennis
> > Woods Creek Wholesale Nursery
> > Monroe, WA

 
 
 

How to display JPEG files?

Post by Scott Seligma » Thu, 05 Dec 2002 10:14:16



Quote:> In the mean time, does anyone else have any example code for displaying
> JPEGs on a PPC?   Or maybe a reference to a discussion on how to use the
> four APIs I see exposed in the imgdecmp.h file?

I have some sample code to do this at:

http://www.scottandmichelle.net/scott/code/code-088.html

--
                                      Scott Seligman
  http://www.scottandmichelle.net/scott/cestuff.html
    (Replace devnull with my first name to email me)

 
 
 

How to display JPEG files?

Post by devr » Thu, 05 Dec 2002 10:39:02


ResetObj() is a custom function I add to many of my classes... It is
basically a destructor and initializer, but not an offical ~ one. It allows
me to reuse object instances. In this case all it does is free the HBITMAP
in my custom bitmap class, nothing related to the imgdecmp.dll.  Also In the
objects real destructor I call FreeLibrary();

I sure would like to figure out why this code is causing ActiveX controls
not to load (DLL not found is the error I get). Wonder if im doing something
wrong? Anyone else had this problem?

-


> Devr,

> Thanks for the source.   I've been looking through it and it looks good.
I
> have a question though.   What's ResetObj() do?

> Thanks!
> --
> Dennis
> Woods Creek Wholesale Nursery
> Monroe, WA



> > Im using imgdecmp to load jpegs right now. It works but seems to have a
> bug
> > where I cannot load COM/ActiveX objects after I have used it.... ? I am
> also
> > using libjpeg (free) for saving jpegs, so I will probably swtich to that
> for
> > loading also. Heres some code I ripped and modifed from the imgdecomp
> > samples. HTH

> > // Initialize. ResetsObj()!
> > // (RETURNS: 0 on failure)
> > int BmpImageLoader::Init(){

> >  ResetObj();           // Reset

> >  // Load dll & procedure address if not loaded. Do it once (ResetObj()
> does
> > not
> >  // ..unload the dll in other words. There is no reason to)
> >  if ( !hDeCmpDLL ){
> >   hDeCmpDLL = LoadLibrary( _T("imgdecmp.dll") );
> >   if ( !hDeCmpDLL )
> >    return 0;
> >  }

> >  if ( !DLLImageLoad ){
> >   DLLImageLoad = (HRESULT(*)(DecompressImageInfo
> > ))GetProcAddress( hDeCmpDLL,
> >    _T("DecompressImageIndirect") );
> >   if ( !DLLImageLoad )
> >    return 0;
> >  }

> >  return 1;           // success
> > }

> > // Load bitmap.
> > // (PASS: hdc image will be used with, file name)
> > // (RETURNS: 0 on failure)
> > int BmpImageLoader::Load( HDC hdc, LPCTSTR file_name ){

> >  // we must be initialized to load
> >  if ( !hDeCmpDLL || !DLLImageLoad )
> >   return 0;          // failure

> >  ResetObj();           // reset

> >  // if file_name is NULL, we are done.
> >  if ( file_name == NULL )
> >   return 1;          // success

> >  // open the file
> >  HANDLE hfile = CreateFile( file_name, GENERIC_READ, FILE_SHARE_READ,
> NULL,
> >   OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );

> >  if (hfile == INVALID_HANDLE_VALUE)
> >   return 0;          // failure

> >  // Fill in the 'DecompressImageInfo' structure
> >  BYTE    buffer[1024] = {0};
> >  HBITMAP hbmp = NULL;
> >  DecompressImageInfo dii;

> >  dii.dwSize = sizeof( DecompressImageInfo );  // Size of this structure
> >  dii.pbBuffer = buffer;       // Pointer to the buffer to use for data
> >  dii.dwBufferMax = 1024;       // Size of the buffer
> >  dii.dwBufferCurrent = 0;      // The amount of data which is current in
> the
> > buffer
> >  dii.phBM = &hbmp;        // Pointer to the bitmap returned (can be
NULL)
> >  dii.ppImageRender = NULL;      // Pointer to an IImageRender object
(can
> be
> > NULL)
> >  dii.iBitDepth = GetDeviceCaps( hdc,BITSPIXEL ); // Bit depth of the
> output
> > image
> >  dii.lParam = ( LPARAM ) hfile;     // User parameter for callback
> functions
> >  dii.hdc = hdc;         // HDC to use for retrieving palettes
> >  dii.iScale = 100;        // Scale factor (1 - 100)
> >  dii.iMaxWidth = 10000;       // Maximum width of the output image
> >  dii.iMaxHeight = 10000;       // Maxumum height of the output image
> >  dii.pfnGetData = DeCmp_GetData;     // Callback function to get image
> data
> >  dii.pfnImageProgress = DeCmp_ImageProgress;  // Callback function to
> notify
> > caller of progress decoding the image
> >  dii.crTransparentOverride = ( UINT ) -1;  // If this color is not
> (UINT)-1,
> > it will override the
> >              // transparent color in the image with this color. (GIF
ONLY)

> >  // Process and decompress the image data
> >  HRESULT hr = DLLImageLoad( &dii );

> >  // close file
> >  CloseHandle( hfile );

> >  // test hr
> >  if ( FAILED( hr ) )
> >   return 0;         // failure

> >  // attach the hbmp
> >  Bitmap.Attach( hbmp );

> >  return 1;         // success
> > }

> > // DeCmp dll get image data callback. lparam is a file handle, just read
> the
> > file.
> > DWORD CALLBACK BmpImageLoader::DeCmp_GetData( LPSTR buffer, DWORD
> > max_buffer,
> >             LPARAM lparam ){

> >  DWORD num_red;

> >  if ( (HANDLE)lparam == INVALID_HANDLE_VALUE )
> >   return 0;

> >  ReadFile( (HANDLE)lparam, buffer, max_buffer, &num_red, NULL );

> >  // Return number of bytes read
> >  return num_red;
> > }

> > // DeCmp progress callback.
> > void CALLBACK BmpImageLoader::DeCmp_ImageProgress( IImageRender
*prender,
> >  BOOL bcomplete, LPARAM lparam ){

> >  if( bcomplete ){
> >   ;// (Optional) add code here for completion processing
> >  }
> > }



> > > Recently, in this group, I saw a question asked about displaying JPEG
> > files.
> > > There were two answers.   One from "Perpetual Projects" said to
include
> > > "imgdecmp.h" and gave some sample code.   The other, from "Ron
Craswell"
> > > suggested using a free wrapper class (from
> > > http://www.voscorp.com/asp/PPC/Dev/VOImage/default.asp) which wraps
the
> > > imgdecmp.dll.

> > > "Perpetual Projects"s example looked to me as if it was chopped and
only
> > > part of the example was present.   I've written him to see if I can
get
> > the
> > > full listing.

> > > In the mean time, does anyone else have any example code for
displaying
> > > JPEGs on a PPC?   Or maybe a reference to a discussion on how to use
the
> > > four APIs I see exposed in the imgdecmp.h file?

> > > Anyone have any experiences good or bad with the wrapper class Ron
> > Craswell
> > > suggested?

> > > Many thanks!

> > > --
> > > Dennis
> > > Woods Creek Wholesale Nursery
> > > Monroe, WA

 
 
 

1. What is the best way 2 programmatically display graphics files (ie JPEG, BMP) in Pocket PC?

Hi!

I'm new to Pocket PC multimedia, I'm trying to research the best way to
display (also zooming, etc) graphics file (ie JPEG, BMP) in a PDA (ie HP
Jornada) running Pocket PC. How can I do this programmatically? Is it better
to use GAPI, DirectX or just use the GDI APIs?

Can you give me some good websites where I can download some good samples on
how to do this?

Any help is greatly appreciated. Thank you in advance.

Regards,
Mon

2. How can I get data from NotesPump REALTIME into a keywordlist and/or a textlist?? PLEASE HELP!!!

3. Problem to display JPEG with imdecmp.dll...

4. Please Read and respond ASAP!!!

5. Display JPEG using Embedded Visual C++

6. ptkImportantMessage

7. Displaying GIF and JPEGs in HTML Viewer Control

8. Files don't always show when requested from the Word program

9. Need source code to display large tiff,bmp,jpeg pictures on Ipaq

10. How to develop a application which can display JPEG image with eVC 4.0?

11. Cannot open JPEG & PDF files from Pocket File Explorer

12. Jpeg files on a PPC

13. PPC2002 - Viewing JPEG Files