[Q] PtWriteImage (the return ...)

Hello,

I’m trying to use PxWriteImage, but I’m a bit fuzzy on how to use it … I
could’nt found any informations on it … :frowning: I hear that a new way of
loading/writing image is coming, but doesn’t looks like it’s on the 6.1
yet …

In PxImage.h, the prototype of the function is :

int PxWriteImage( char const *filename, PhImage_t const *image, PxMethods_t
const *methods, int iformat, int itype );

Which elements (if any) of the methods struct should be set ? The argument
iformat is obviously the format of the image file to create, but the last
argument is totaly unknown to me …

Thanks for any help, I need to write JPEG and this function look pretty
handy.

Regards,

jean-louis

nevermind … I find out to use the new Pi* functions
and they works better than the old one :slight_smile:

jl

Hi Jean-Louis,

I have the same problem, lots of trouble using Px…Image functions on 6.1
Did you find any help/documentation on those Pi… functions?

TIA
-hp

“Jean-Louis Villecroze” <jlv@kirilla.com> schrieb im Newsbeitrag
news:9jfdcj$l7n$1@inn.qnx.com

nevermind … I find out to use the new Pi* functions
and they works better than the old one > :slight_smile:

jl

In message <9jggsj$aci$1@inn.qnx.com>, “HP Reichert” wrote:

Hi Jean-Louis,

I have the same problem, lots of trouble using Px…Image functions on 6.1
Did you find any help/documentation on those Pi… functions?

Hello,

I used the include and some helps from Cdm (from #qnx chat) … I will post
you the function to load/save an image next time (I’m not under QNX right
now)

regards

jean-louis

Hi,

So here the 2 functions I did to load/save
a JPEG file … you need to add this :

#include <photon/imaging/PiIo.h>

To load/save another type of image. simply
change “jpg” by the extension …

Note that writing GIF doesn’t work.

Regards,

jean-louis


/*

  • Function : LoadImage
  • Purpose : Load a given image
  • Inputs :
  • char *filename, filename of the image to load
  • Output : PhImage_t *, NULL if failed
  • Side Effects : none
    */
    PhImage_t *LoadImage(char *filename)
    {
    PhImage_t *img;
    PiLoadInfo_t info;
    PiIoHandler_t *handler;

handler = PiIoGetHandlerByExt(“jpg”);

memset(&info,NULL,sizeof(PiLoadInfo_t));

info.handler = handler;
info.filename = filename;

img = PiLoadImage(&info);
if(img)
img->flags |= Ph_RELEASE_IMAGE_ALL;

return img;
}

/*

  • Function : SaveImage
  • Purpose : Save a given image
  • Inputs :
  • PhImage_t *img, image to save
  • char *filename, filename of the image to save
  • Output : PhImage_t *, NULL if failed
  • Side Effects : none
    */
    bool SaveImage(PhImage_t *img,char *filename)
    {
    PiWriteInfo_t info;
    PiIoHandler_t *handler;

handler = PiIoGetHandlerByExt(“jpg”);

memset(&info,NULL,sizeof(PiWriteInfo_t));

info.handler = handler;
info.filename = filename;
info.image = img;
return PiWriteImage(&info);
}

thanks