![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 .. |
|
||||
|
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.. |
|
|||||
|
Quote:
Here is a tutorial on DevIL. It includes an example of how to load and display a JPEG using 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 .. |
|
||||
|
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 | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|