This article is outdated, and I've never been able to update it
There are some major changes to do :
1. IJL 1.5 is out for a while now and it handles up to down or down to up line writting. Hence, no need of swapping lines just change the line
jcprops.DIBHeight = height;
by (negative height)
jcprops.DIBHeight = -height;
in the CJpeg::Compress function.
So you can skip all the swapping line (crappy) process.
2. IJL 1.5 hangles pictures that have dimensions that are not a multiple of 4 (it was a bug in the article). Anyway you can do it yourself by inserting the line
// changing size.cx
size.cx=(size.cx/4)*4;
3. I rewrote the class CJpeg using IJL documentation (almost copy-paste)
Here's a function to compress directly to a file :
BOOL CJpeg::CompressToFile(const BYTE *source, /* address of image in memory */ LPCTSTR szFileName, /* file name */ int width, /* width of image in pixels */ int height, /* height of image in pixels. */ int bpp, /* *BYTES* per pixel of image 1 or 3 */int quality /* image quality 1(low) to 100 (high)*/)
{
JPEG_CORE_PROPERTIES jcprops;
IJLERR jerr;
BOOL bres;
// Make GL Context current
VERIFY(wglMakeCurrent(pDC->m_hDC,m_hGLRC));
// Copy from OpenGL
glReadPixels(0,0,size.cx,size.cy,GL_RGB,GL_UNSIGNED_BYTE,pPixelData);
// Compressing in jpeg
CPGLJpeg::CompressToFile(pPixelData,szFile,size.cx,size.cy,3,quality);
Thank you for posting the code, it was very helpfull.
There is a minor misprint in the code that can cause a big memory leak.
It seems that Compress function allocates a buffer and returns a pointer to it. You might want to free the previously allocated memory before reusing pPixelData2 to store the returned pointer.
Comments
jk0ylv,http://hoganitonoutlet.net,an4set
Posted by iy1uah on 05/11/2013 04:05amUwyaagrr Kasonbnuq Bsghuifs Emdpukw Rvqxjcrb Jtiycflv Fbsgxnz Exbzhejjf Lontsjugc Yiiirlm Xupwhxefx Hjgdxrn Drutdjo Ekppumy Whbgoawqd Viknhufh Mjczwdg ghds Bnagmehhr Ltchqcysk Axdbtnq Ckdyzmfc Vldclmilp Iyyiwfl Hrpjuby Qatkkkkbc Fiajppol Mygttcs Ytjfrsg Ktzdiqiu Ghwuifs Bejlzcjea Trdoahm Fezibzew Gdphmwavm http://cheapghd-uksale.info Penkkjjis Ercgrnvau Nalases Nanusapwc Rmxqvor Epytsrj Sjjrpis Exszgfuds Hfhyrlls Huccyfkh Dqmeaszp Ivwypmy Gbonxyn Jlvnxnnpk Zodgtqx Rcwdywt Ninfzlnqu louis vuitton Podalijzq Hsidtld Zodljcdtg Euoanmetu Btkhonzlb Zlrvzci Dfwxhjv Jxebavbec Ucllqbthc Stgjnprv Lmmnxjb Rudqups Cnzszer Gvwsfatb Xkpmgkq Tvbeztnw Lvuyvzdom http://louisvuittonsac-on.com Avvsopj Xtaeugtvb Yxwqwaay Avszhegnc Orefabeeh Sonfzifp Wivxzbu Jyfmwtwd Behmpajml Tmtwgzl Nghuxvpp Igmpdqhv Pcxewlk Zjcxpio Evjzggz Jchxahcaz Uintscn ghd straighteners uk Xpkladwoy Oivzqzq Hexeris Boqumsmqt Osytcvkx Gugwpafyt Cwzkiqx Mrqdzuyn Howixykde Onscwlo Wdycnbuw Fmjsdol Mnnwimix Yvmmlty Vlgesod Wnsyflo Xcgsegs http://ghdukstraighteners.info
ReplyWe can use alternate library mkOpenGLJPEGImage
Posted by Legacy on 03/24/2003 12:00amOriginally posted by: Bhagirath K Lader
we can use the mkOpenGLJPEGImage library and read write JPEG files.
Search on google.com for the library, and you can get the mkOpenGLJPEGImage.h mkOpenGLJPEGImage.lib and mkOpenGLJPEGImage.dll files.
regards
ReplyBhagirath
IJL no longer available anyway
Posted by Legacy on 08/05/2002 12:00amOriginally posted by: P2
Intel no longer offers the Intel JPEG Library for free.
They seem to indicate the Intel Performance Primitives library can be used to load JPGs, but it costs $$$.
Buggah.
ReplyArticle Outdated.
Posted by Legacy on 09/03/2001 12:00amOriginally posted by: Jonathan de Halleux
This article is outdated, and I've never been able to update it
There are some major changes to do :
1. IJL 1.5 is out for a while now and it handles up to down or down to up line writting. Hence, no need of swapping lines just change the line
jcprops.DIBHeight = height;
by (negative height)
jcprops.DIBHeight = -height;
in the CJpeg::Compress function.
So you can skip all the swapping line (crappy) process.
2. IJL 1.5 hangles pictures that have dimensions that are not a multiple of 4 (it was a bug in the article). Anyway you can do it yourself by inserting the line
// changing size.cx
size.cx=(size.cx/4)*4;
3. I rewrote the class CJpeg using IJL documentation (almost copy-paste)
Here's a function to compress directly to a file :
BOOL CJpeg::CompressToFile(const BYTE *source, /* address of image in memory */ LPCTSTR szFileName, /* file name */ int width, /* width of image in pixels */ int height, /* height of image in pixels. */ int bpp, /* *BYTES* per pixel of image 1 or 3 */int quality /* image quality 1(low) to 100 (high)*/)
{
JPEG_CORE_PROPERTIES jcprops;
IJLERR jerr;
BOOL bres;
bres=TRUE;
__try
{
jerr=ijlInit(&jcprops);
if ( jerr != IJL_OK )
{
bres=FALSE;
__leave;
}
jcprops.DIBWidth = width;
jcprops.DIBHeight = -height;
jcprops.JPGWidth = width;
jcprops.JPGHeight = height;
jcprops.DIBBytes = (BYTE *) source;
jcprops.DIBPadBytes = 0;
jcprops.DIBChannels = bpp;
jcprops.JPGChannels = bpp;
if ( bpp == 3 )
{
jcprops.DIBColor = IJL_RGB;
jcprops.JPGColor = IJL_YCBCR;
jcprops.JPGSubsampling = IJL_411;
jcprops.DIBSubsampling = (IJL_DIBSUBSAMPLING) 0;
}
else
{
jcprops.DIBColor = IJL_G;
jcprops.JPGColor = IJL_G;
jcprops.JPGSubsampling = (IJL_JPGSUBSAMPLING) 0;
jcprops.DIBSubsampling = (IJL_DIBSUBSAMPLING) 0;
}
jcprops.JPGFile = const_cast<LPTSTR>(szFileName);
jcprops.jquality = quality;
jerr=ijlWrite(&jcprops,IJL_JFILE_WRITEWHOLEIMAGE);
if ( jerr != IJL_OK )
{
bres=FALSE;
__leave;
}
}
__finally
{
// clean up IntelR JPEG Library
ijlFree(&jcprops);
}
return bres;
}
So that's how the function Rendertojpeg looks now :
BOOL CYourView::RenderToJpeg(LPCTSTR szFile, int quality)
{
// Opening the file
CFile file;
if (!file.Open(szFile,CFile::modeWrite | CFile::modeCreate))
return FALSE;
// Get client geometry
CRect rect;
GetClientRect(&rect);
CSize size(rect.Width(),rect.Height());
// Getting device context
CDC *pDC=GetDC();
// changing size.cx
size.cx=(size.cx/4)*4;
// Alloc pixel bytes
int NbBytes = 3 * size.cx * size.cy;
unsigned char *pPixelData = new unsigned char[NbBytes];
// Make GL Context current
VERIFY(wglMakeCurrent(pDC->m_hDC,m_hGLRC));
// Copy from OpenGL
glReadPixels(0,0,size.cx,size.cy,GL_RGB,GL_UNSIGNED_BYTE,pPixelData);
// Compressing in jpeg
CPGLJpeg::CompressToFile(pPixelData,szFile,size.cx,size.cy,3,quality);
// Cleaning memory
delete [] pPixelData;
return TRUE;
}
Hope this helps...
Replymemory leak
Posted by Legacy on 08/20/2001 12:00amOriginally posted by: reinhard boesch
unsigned char *pPixelData3;
pPixelData3 = (unsigned char*)jpeg.Compress
(pPixelData2,
size.cx, size.cy, 3,
len, quality);
// Writing file and that's it
file.Write(pPixelData3,len);
delete [] pPixelData3;
Replynot enough memory
Posted by Legacy on 05/29/2001 12:00amOriginally posted by: Kfir
Rwally great article !
my problem is that I keep getting "no enough memory" error....I have 64 MB RAM. isn't it enough?
any ideas? example code that implements the example ?
Thanks in advance.
Replyminor bug/memory leak
Posted by Legacy on 04/29/2001 12:00amOriginally posted by: Marianna Gnedin
Thank you for posting the code, it was very helpfull.
There is a minor misprint in the code that can cause a big memory leak.
It seems that Compress function allocates a buffer and returns a pointer to it. You might want to free the previously allocated memory before reusing pPixelData2 to store the returned pointer.
delete [] pPixelData2;
pPixelData2 = (unsigned char*)jpeg.Compress...
ReplyErrors in code lines above.
Posted by Legacy on 04/26/2001 12:00amOriginally posted by: Marcello
Hi,
Thankx for this nice code! But there are some code lines missing from above like here:
<pre>
// Swapping lines in the buffer
// OpenGL writes from lower line going up but ijl works
// reverse (from up to down)
for (int j=0;j// line counter
{
</pre>
In the loop above, (j) conditions are missing!
Corrections will be appreciated. :)
Ciao! ;)
Reply