The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
i am new to opengl , how to work opengl in ubuntu Ravikishore Ubuntu 7 09-03-2009 10:45 AM
Help to decode in perl script kallol High Level Programming 6 08-29-2009 06:27 AM
auto decode a value to different value nhatch Shell Programming and Scripting 2 05-16-2007 12:01 PM
Decode email mskarica Shell Programming and Scripting 6 03-18-2005 01:31 AM
Please decode in English ST2000 Shell Programming and Scripting 4 07-16-2002 01:33 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 2 Weeks Ago
Ravikishore Ravikishore is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 29
Post How to Decode an image using openGL

Hi,

How to decode an image using openGL library libjpeg ..
which are the steps needed to do this using C language..
actually my work is to decode the image, store it on the buffer,
and place it on cube surface..

please guide me,,any answer will appreciated ..
  #2 (permalink)  
Old 2 Weeks Ago
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,912
Here is one way of finding source code examples of how to use libjpeg to decode a JPEG image.
  #3 (permalink)  
Old 2 Weeks Ago
Ravikishore Ravikishore is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 29
Post how to display, after decoding an image in openGL

Hi,

Thank you so much for your help.. it helps me a lot..
as i am new to openGL. i dont know whether it is a basic question which i am asking know.
the question is :

The program jpeg_sample.c which is there in tar file is executing with out any error ..
i think decompression is done well ,,
but its not displaying any JPEG image after execution ...

Could you tell how to display jpeg image after decoding in openGL

and i am not getting from where it is taking an jpeg image in that code ..

Please guide me , any answer will appreciated..
  #4 (permalink)  
Old 2 Weeks Ago
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,928
We cannot see the source code from here.
  #5 (permalink)  
Old 2 Weeks Ago
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,912
Quote:
Could you tell how to display jpeg image after decoding in openGL
Given that you do not appear to much experience with the concept of textures in OpenGL, maybe you should use an image library such as DevIL.

Here is a tutorial on DevIL. It includes an example of how to load and display a JPEG using OpenGL.
  #6 (permalink)  
Old 2 Weeks Ago
Ravikishore Ravikishore is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 29
Post how to display, after decoding an image in openGL

Hi,

The source code is:

#include <stdio.h>
#include <jpeglib.h>
#include <stdlib.h>


unsigned char *raw_image = NULL;

int width = 2000;
int height = 1300;
int bytes_per_pixel = 3;
int color_space = JCS_RGB;



int read_jpeg_file( char *filename )
{

struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;



JSAMPROW row_pointer[1];

FILE *infile = fopen( filename, "rb" );
unsigned long location = 0;
int i = 0;

if ( !infile )
{
printf("Error opening jpeg file %s\n!", filename );
return -1;
}

cinfo.err = jpeg_std_error( &jerr );

jpeg_create_decompress( &cinfo );

jpeg_stdio_src( &cinfo, infile );

jpeg_read_header( &cinfo, TRUE );


printf( "JPEG File Information: \n" );
printf( "Image width and height: %d pixels and %d pixels.\n", cinfo.image_width, cinfo.image_height );
printf( "Color components per pixel: %d.\n", cinfo.num_components );
printf( "Color space: %d.\n", cinfo.jpeg_color_space );


jpeg_start_decompress( &cinfo );


raw_image = (unsigned char*)malloc( cinfo.output_width*cinfo.output_height*cinfo.num_components );

row_pointer[0] = (unsigned char *)malloc( cinfo.output_width*cinfo.num_components );

while( cinfo.output_scanline < cinfo.image_height )
{
jpeg_read_scanlines( &cinfo, row_pointer, 1 );
for( i=0; i<cinfo.image_width*cinfo.num_components;i++)
raw_image[location++] = row_pointer[0][i];
}

jpeg_finish_decompress( &cinfo );
jpeg_destroy_decompress( &cinfo );
free( row_pointer[0] );
fclose( infile );

return 1;
}


int write_jpeg_file( char *filename )
{
struct jpeg_compress_struct cinfo;
struct jpeg_error_mgr jerr;


JSAMPROW row_pointer[1];
FILE *outfile = fopen( filename, "wb" );

if ( !outfile )
{
printf("Error opening output jpeg file %s\n!", filename );
return -1;
}
cinfo.err = jpeg_std_error( &jerr );
jpeg_create_compress(&cinfo);
jpeg_stdio_dest(&cinfo, outfile);


cinfo.image_width = width;
cinfo.image_height = height;
cinfo.input_components = bytes_per_pixel;
cinfo.in_color_space = color_space;

jpeg_set_defaults( &cinfo );

jpeg_start_compress( &cinfo, TRUE );

while( cinfo.next_scanline < cinfo.image_height )
{
row_pointer[0] = &raw_image[ cinfo.next_scanline * cinfo.image_width * cinfo.input_components];
jpeg_write_scanlines( &cinfo, row_pointer, 1 );
}

jpeg_finish_compress( &cinfo );
jpeg_destroy_compress( &cinfo );
fclose( outfile );

return 1;
}

int main()
{
char *infilename = "rro1.bmp", *outfilename = "rr.jpg";



if( read_jpeg_file( infilename ) > 0 )
{

if( write_jpeg_file( outfilename ) < 0 ) return -1;
}
else return -1;



return 0;
}



This code is working without any error message. but Displayed image is not decompressed .. Image is not a clear picture after decompressed ..
i need to display a decompressed JPEG image at the out put..

Please help me out with this problem,,,any answer will appreciated ..
  #7 (permalink)  
Old 1 Week Ago
Ravikishore Ravikishore is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 29
Post How to insert JPEGs on each side of the cylinder using openGL

Hi,

Sorry for late reply , i got the result of decompressed image, but now i need to insert images on Cylinder surfaces.

Please Help me out ...answer will appreciated ...
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0