Board index » cppbuilder » Save as JPG

Save as JPG


2005-04-29 11:33:31 PM
cppbuilder107
Hi All
I'm pretty new to c programming, and have a little question.
I'm writing a web-cam application (it's a very long story, but my 'normal'
web-cam software will not work with my capture card).
I have a timer running which will grab a single frame, and then FTP it to my
web-site. This works reliably, but I'm using capFileSaveDIB which produces a
bmp file. Is there an easy way to convert to (or save as) a jpg ?
TIA
 
 

Re:Save as JPG

"Grumps" < XXXX@XXXXX.COM >wrote in message
Quote
Is there an easy way to convert to (or save as) a jpg ?
Load the DIB into a TBitmap and then Assign() it to a TJPEGImage. For
example:
if( capFileSaveDIB(hCapWnd, "c:\\folder\\file.bmp") )
{
Graphics::TBitmap *bmp = new Graphics::TBitmap;
try
{
bmp->LoadFromFile("c:\\folder\\file.bmp");
TJPEGImage *jpg = new TJPEGImage;
try
{
jpg->Assign(bmp);
jpg->SaveToFile("c:\\folder\\file.jpg");
}
__finally {
delete jpg;
}
}
__finally {
delete bmp;
}
}
Gambit
 

Re:Save as JPG

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Grumps" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>Is there an easy way to convert to (or save as) a jpg ?

Load the DIB into a TBitmap and then Assign() it to a TJPEGImage. For
example:

if( capFileSaveDIB(hCapWnd, "c:\\folder\\file.bmp") )
{
Graphics::TBitmap *bmp = new Graphics::TBitmap;
try
{
bmp->LoadFromFile("c:\\folder\\file.bmp");
TJPEGImage *jpg = new TJPEGImage;
try
{
jpg->Assign(bmp);
jpg->SaveToFile("c:\\folder\\file.jpg");
}
__finally {
delete jpg;
}
}
__finally {
delete bmp;
}
}
Thanks.
Just what I needed.
 

{smallsort}