PxLoadImage fails, but errno is EOK!

I have code making a call to PxLoadImage(). PxLoadImage() is
returning NULL, but errno is EOK.

if( ( pimage == PxLoadImage( “/minya/db/calib.jpg”, NULL )) == NULL )
{
perror( “Unable to load calib.jpg file” ) ;
return ;
}

prints error

Unable to load calib.jpg file: No error

Anyone seen this before?

The file is readable with the image viewer.

This is QNX 4.25, Photon 1.14

TIA

Ken Schumm <kwschumm@qsolv.com> wrote:

This would probably end up with a better response in the photon newsgroup…

I have code making a call to PxLoadImage(). PxLoadImage() is
returning NULL, but errno is EOK.

IIRC, there is a common gotcha with the PxLoadImage family of functions –
you have to use some macros to define what image types you want support
for before including the <photon/PxImage.h> header file.

Specifically, did you:

#define PX_IMAGE_MODULES
#define PX_JPG_SUPPORT
#include <photon/PxImage.h>

Not a photon expert, so if that isn’t it… I’d suggest going to the
photon newsgroup.

-David

QNX Training Services
dagibbs@qnx.com

“David Gibbs” <dagibbs@qnx.com> wrote in message
news:96h4be$jg9$2@nntp.qnx.com

Ken Schumm <> kwschumm@qsolv.com> > wrote:

This would probably end up with a better response in the photon
newsgroup…

I have code making a call to PxLoadImage(). PxLoadImage() is
returning NULL, but errno is EOK.

IIRC, there is a common gotcha with the PxLoadImage family of functions –
you have to use some macros to define what image types you want support
for before including the <photon/PxImage.h> header file.

Specifically, did you:

#define PX_IMAGE_MODULES
#define PX_JPG_SUPPORT
#include <photon/PxImage.h

Not a photon expert, so if that isn’t it… I’d suggest going to the
photon newsgroup.

exactly this way. just wan to add a working example code for loading
images in .gif and .jpeg format.


#include <Ph.h>
#include <Pt.h>
#include <Ap.h>

#define PX_IMAGE_MODULES /* required for images load module support
/
#define PX_GIF_SUPPORT /
required for images in .gif format
/
#define PX_JPG_SUPPORT /
required for images in .jpeg format
*/

/*

  • add another PX_xxx_SUPPORT defines from photon/PxImage.h if you need
    other image file formats
    */

#include <photon/PxImage.h>
#include <photon/PxProto.h>

#define LOAD_IMAGE_COLORS 256 /* load only 8bit images */

typedef struct image_s {
PhImage_t *data;
} image_t;

static int load_image_file(const char *path, image_t *image) {
PxMethods_t pxm;
PhImage_t *data;
char index;
int colors;
int result;
result = -1;

/* reset load methods structure */
memset(&pxm,0,sizeof(pxm));

/* request to query image info */
pxm.flags = PX_QUERY;

/* query if source file can be load in any of supported formats */
if ((data = PxLoadImage(path,&pxm)) != NULL) {

/* get number of colors of loadding image */
colors = data->colors;
PhReleaseImage(data);

/* check if number of colors matches */
if (colors == LOAD_IMAGE_COLORS) {

/* reset load methods structure */
memset(&pxm,0,sizeof(pxm));

/* request to load image file */
pxm.flags = PX_LOAD;

if ((data = PxLoadImage(path,&pxm)) != NULL) {

/*

  • here’s a little classical trick - use left up pixel color
    as transparency color for whole image
  • tre trouble is that .gif format with transparency exists
    over 10 years
  • but gentlemens coded phab libraries yet cannot learn how
    to load it correctly…
    */

/* so get left-up pixel rgb value from image data map */
index = ((char)data->image);

/* make transparence mask for this image based on this rgb
*/
if (PhMakeTransBitmap(data,index | Pg_INDEX_COLOR) == 0) {

/* well, make also ghost image of course if you need it
:slight_smile: /
if (PhMakeGhostBitmap(data) == 0) {
image->data = data;
result = 0;
}
}
if (result == -1) PhReleaseImage(data);
}
}
}
return result;
} /
load_image_file */


-David

QNX Training Services
dagibbs@qnx.com


Ian Zagorskih
Novosoft CyBearNet Department
Custom software development and web design since 1992
E-mail: ianzag@novosoft.ru
Phone: +7 (3832) 39-72-60, 39-72-61
Fax: +7 (3832) 39-63-58
For more visit www.novosoft-us.com

Previously, David Gibbs wrote in qdn.public.qnx4:

Ken Schumm <> kwschumm@qsolv.com> > wrote:

This would probably end up with a better response in the photon newsgroup…

Sorry. I saw qdn.public.photon was dead, and missed the qdn.public.qnx4.photon
in the tree.

I have code making a call to PxLoadImage(). PxLoadImage() is
returning NULL, but errno is EOK.

IIRC, there is a common gotcha with the PxLoadImage family of functions –
you have to use some macros to define what image types you want support
for before including the <photon/PxImage.h> header file.

Specifically, did you:

#define PX_IMAGE_MODULES
#define PX_JPG_SUPPORT
#include <photon/PxImage.h

Not a photon expert, so if that isn’t it… I’d suggest going to the
photon newsgroup.

Did that, no diff. I’ll go over to the photon ng.

-David

QNX Training Services
dagibbs@qnx.com

Previously, Ian M. Zagorskih wrote in qdn.public.qnx4:

“David Gibbs” <> dagibbs@qnx.com> > wrote in message
news:96h4be$jg9$> 2@nntp.qnx.com> …
Ken Schumm <> kwschumm@qsolv.com> > wrote:

[]

Thanks for the example, Ian. I’ll look it over.

The example I originally presented was lifted, almost verbatim
from the PgDrawImage() docs, but it didn’t seem to work.