Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

p.p1 {margin: 5.0px 0.0px 5.0px 0.0px; font: 12.0px 'Times New Roman'}
span.s1 {color: #ffffff}

Hi

I ma using Brew 3.1.5

IImage * ISHELL_LoadImage (IShell * pIShell, const char * pszImageFile) 

if pszImageFile = myfile.jpg then it works but if oszImageFile = myfile.tmp then it does not

Does the extension matter ?

Thank you

yes. it seems IImage_LoadImage() uses file extension to recognise the image class to be used. if you do not specify the file extension it would fail to load the image.
Alternatlly you may use IImage_SetStream(), but you need to know the image type in advance.
To identify the image type you may read the starting bytes in the file.
eg: For JPEG file first 2 bytes are FFD8 (hex).
 
Using IImage_SetStream:
 
void loadImageStream(myApp*pMe)
{
IFile *pFile;
IFileMgr *pFileMgr;
IImage *pImage;

if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_JPEG, (void**)&pImage) != SUCCESS) {
return;
}

if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_FILEMGR, (void**)&pFileMgr) != SUCCESS) {
return;
}

pFile = IFILEMGR_OpenFile(pFileMgr, "un-lock.tmp", _OFM_READ);

IIMAGE_SetStream(pImage, (IAStream*)pFile);

IIMAGE_Notify(pImage, (PFNIMAGEINFO)imageNotify, pMe);

RELEASEIF(pFileMgr);

void imageNotify(myApp *pMe, IImage *pImage, AEEImageInfo * pi, int nErr)
{
if(pImage){
IIMAGE_Draw(pImage, 0, 0);
}
IDISPLAY_Update(pMe->a.m_pIDisplay);

yes. it seems IImage_LoadImage() uses file extension to recognise the image class to be used. if you do not specify the file extension it would fail to load the image.
Alternatlly you may use IImage_SetStream(), but you need to know the image type in advance.
To identify the image type you may read the starting bytes in the file.
eg: For JPEG file first 2 bytes are FFD8 (hex).
 
Using IImage_SetStream:
 
void loadImageStream(myApp*pMe)
{
IFile *pFile;
IFileMgr *pFileMgr;
IImage *pImage;

if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_JPEG, (void**)&pImage) != SUCCESS) {
return;
}

if(ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_FILEMGR, (void**)&pFileMgr) != SUCCESS) {
return;
}

pFile = IFILEMGR_OpenFile(pFileMgr, "un-lock.tmp", _OFM_READ);

IIMAGE_SetStream(pImage, (IAStream*)pFile);

IIMAGE_Notify(pImage, (PFNIMAGEINFO)imageNotify, pMe);

RELEASEIF(pFileMgr);

void imageNotify(myApp *pMe, IImage *pImage, AEEImageInfo * pi, int nErr)
{
if(pImage){
IIMAGE_Draw(pImage, 0, 0);
}
IDISPLAY_Update(pMe->a.m_pIDisplay);