|
From: Jeroen v. d. Z. <jv...@cf...> - 2001-12-11 16:11:14
|
On Tuesday 11 December 2001 09:36, you wrote:
> > > > Typical steps would be:
> > > > FXuchar *data;
> > > > FXint width,height,qual;
> > > > FXColor trans;
> > > > FXFileStream store;
> > > >
> > > > store.open(filename,FXStreamLoad);
> > > > fxloadJPG(store,data,trans,width,height,qual);
> > > > store.close();
> > > >
> > > > Note we have blatantly ignored errors; production code would test for
> > > > various errors, of course.
> > > >
> > > > Then, pass to OpenGL:
> > > >
> > > > glPixelStorei(GL_UNPACK_ALIGNMENT,1);
> > > > glGenTextures(1, &texname);
> > > > glBindTexture(GL_TEXTURE_2D,texname);
> > > > glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
> > > > glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
> > > > glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
> > > > glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
> > > >
> > > > glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,width,height,0,GL_RGB,GL_UNSIGNED
> > > >_BYT E,data);
> > >
> > >
> > > It would seem as there is a problem with the above example.
> > > That is, where is the data stored? All we have is a pointer
> > > to the data. When we call FXFileStream.close() does the data
> > > persist? Has the FXFileStream object allocated the appropriate
> > > room? Or do we need to save the data before calling close()
> > > e.g. using fxSaveJPG()?
> > >
> > > -cheers, bob
> >
> > fxloadJPG allocates the array; it must be freed using FXFREE(&data).
> >
> > Sorry, I should have mentioned that.
> >
> > - Jeroen
>
>
> Thank you for your help thus far Jeroen. It seems to be working
> now. Ok, now i would like to store the JPEG image as part of
> the binary file. i have already used reswrap to save the file
> directly into the executable. e.g. i have this in my header file:
>
> /* Generated by reswrap from file water32x32.jpg */
> const unsigned char m_Water32x32[]={
>
> 0xff,0xd8,0xff,0xe0,0x00,0x10,0x4a,0x46,0x49,0x46,0x00,0x01,0x01,0x00,0x00,
>0x01, ...
>
> Now, what are the steps to take to extract the RGB data.
> If i understand correctly, i first load this data into
> a FOXFileStream object, and then extract the RGB data.
> Is it the same 3 steps (open, load, and close) except
> instead of the filename i pass the array name?
>
> -cheers, bob
Use FXMemoryStream.
FXMemoryStream ms;
FXuchar *data;
FXint width,height,qual;
FXColor trans;
ms.open(m_Water32x32,FXStreamLoad);
fxloadJPG(ms,data,trans,width,height,qual);
ms.close();
Should do the trick. Note works exactly the same as FXFileStream, i.e.
all the I/O working on FXStream's has no idea its coming from file or
memory data arrays.
Regards,
Jeroen
--
+-------------------------------+--------------------------------------------+
| E-Mail : jv...@cf... | The FOX Platform Independent GUI Toolkit: |
| USMail : 215 Wynn Drive, | |
| Huntsville, AL 35805 | Official Site: |
| Phone : (256) 726-4820 | http://www.fox-toolkit.org |
| Fax : (256) 726-4806 | ftp://ftp.fox-toolkit.org/pub |
| WWW : http://www.cfdrc.com | |
+-------------------------------+--------------------------------------------+
| Copyright (C) 15:10 10/10/2001 Jeroen van der Zijp. All Rights Reserved. |
+----------------------------------------------------------------------------+
|