Board index » delphi » jpegs & gifs with BC++?

jpegs & gifs with BC++?

Hello,

Is there a way to display jpeg's and gif's and BC++ 5.01 (preferrably with
OWL)?  Maybe via a custom VBX?

Thanks in advance

 

Re:jpegs & gifs with BC++?


You can use IPicture. I think it needs IExplorer 4.0 or higher.

#include <ocidl.h>
//call CoInitialize() at startup, CoUnInitialize() on exit
//call Picture->Release(); on exit
LPPICTURE Picture=NULL;
bool LoadPictureFile(char *filename)
{
 HANDLE
hfile=CreateFile(filename,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
 if(hfile==INVALID_HANDLE_VALUE) return false;
 int filesize=GetFileSize(hfile, NULL);                                        
 HGLOBAL hglobal=GlobalAlloc(GMEM_MOVEABLE, filesize);  
 LPVOID data=GlobalLock(hglobal);
 DWORD byteread=0;
 ReadFile(hfile,data,filesize,&byteread,NULL);
 GlobalUnlock(hglobal);
 CloseHandle(hfile);
 LPSTREAM pstm=NULL;
 HRESULT hr=CreateStreamOnHGlobal(hglobal, true, &pstm);
 if(!pstm) return false;
 if(hr!=S_OK) {pstm->Release(); return false;}
 if (Picture) Picture->Release();
 Picture=NULL;
 hr=::OleLoadPicture(pstm,filesize,false,IID_IPicture,(LPVOID
*)&Picture);
 if(hr!=S_OK) return false;
 if(!Picture) return false;
 pstm->Release();
 return true;

Quote
}

void PaintPicture(TDC &dc)
{
 if(!Picture) return;
 long src_width,src_height,dst_width,dst_height;
 Picture->get_Width(&src_width);
 Picture->get_Height(&src_height);
 dst_width=src_width*dc.GetDeviceCaps(LOGPIXELSX)/2540.0;
 dst_height=src_height*dc.GetDeviceCaps(LOGPIXELSY)/2540.0;
 TRect rc;

Picture->Render(dc,0,0,dst_width,dst_height,0,src_height,src_width,-src_height,&rc);

Quote
}
Andrey Chernolutskiy wrote:

> Hello,

> Is there a way to display jpeg's and gif's and BC++ 5.01 (preferrably with
> OWL)?  Maybe via a custom VBX?

> Thanks in advance

Re:jpegs & gifs with BC++?


Hello,

Go to Luigi Bianchi's site, http://www.luigibianchi.com
and in the section Uncommon Controls look for the lightweight
GIF/PNG/JPEG control.

Jogy

Quote
"Andrey Chernolutskiy" <AChernoluts...@RGIS.com> wrote in message

news:39e11bd9$1_1@dnews...
Quote
> Hello,

> Is there a way to display jpeg's and gif's and BC++ 5.01 (preferrably with
> OWL)?  Maybe via a custom VBX?

> Thanks in advance

Other Threads