screenshot
hello all.
i want that if the user click on somthing
then my program will create a picture (jpg,gif or somthing)
just like a screen shot.
anyone has any idea how do i do that?
thanks in advance
look at wotsit.org for file formats
use glReadPixels() for getting the screenshot and write the data into the file
use glReadPixels() for getting the screenshot and write the data into the file
-----"Master! Apprentice! Heartborne, 7th Seeker Warrior! Disciple! In me the Wishmaster..." Wishmaster - Nightwish
umm thanks but i got lost in the text file of bmp and i have no idea what to do.
can you please help me? i never created any type or file either
can you please help me? i never created any type or file either
Hi,
Its often easier to use an image library to read/write image files rather than implementing your own.
Some examples: DevIL, Imlib2, SDL_image.
Checkout http://nehe.gamedev.net/ tutorials for some information on using the TGA format too.
Cheers,
dhm
Its often easier to use an image library to read/write image files rather than implementing your own.
Some examples: DevIL, Imlib2, SDL_image.
Checkout http://nehe.gamedev.net/ tutorials for some information on using the TGA format too.
Cheers,
dhm
To mc30900
This reply i posted a few months ago will give you the answer
HERE IS THE ANSWER FOR GRABBING A SCRENSHOT
Trust me it is simple to implement and works 100%... Place this class into your program and away you go
This reply i posted a few months ago will give you the answer
HERE IS THE ANSWER FOR GRABBING A SCRENSHOT
Trust me it is simple to implement and works 100%... Place this class into your program and away you go
Dave 'Kit' Wilson - Reliant Code
And actually, it might be even easier to download the PNG library and use that (its only about 20 lines of code for me...)
infact, here it is:
infact, here it is:
boolcaptureScreen(const char *filename) { FILE *outFile; outFile = fopen(tmpFileName, "wb"); if(outFile == NULL) return false; png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if(!png_ptr) { fclose(outFile); return false; } png_infop info_ptr = png_create_info_struct(png_ptr); if(!info_ptr) { png_destroy_write_struct(&png_ptr, (png_infopp)NULL); fclose(outFile); return false; } if(setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(outFile); return false; } png_init_io(png_ptr, outFile); /* set the zlib compression level */ png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); /* set other zlib parameters */ png_set_compression_mem_level(png_ptr, 8); png_set_compression_strategy(png_ptr, Z_DEFAULT_STRATEGY); png_set_compression_window_bits(png_ptr, 15); png_set_compression_method(png_ptr, 8); png_set_compression_buffer_size(png_ptr, 8192); png_set_IHDR(png_ptr, info_ptr, screenWidth, screenHeight, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); png_write_info(png_ptr, info_ptr); GLubyte *pixels = (GLubyte *)malloc(screenWidth * screenHeight * 3); if(!pixels) return false; glReadPixels(0, 0, screenWidth, screenHeight, GL_RGB, GL_UNSIGNED_BYTE, pixels); GLubyte** rowPtrs = new GLubyte*[screenHeight]; for(GLuint i = 0; i < screenHeight; i++) rowPtrs[screenHeight - i - 1] = &(pixels);<br> <br> png_write_image(png_ptr, rowPtrs);<br> <br> png_write_end(png_ptr, info_ptr);<br> <br> png_destroy_write_struct(&png_ptr, &info_ptr);<br><br> <span class="cpp-keyword">return</span> <span class="cpp-keyword">true</span>;<br>}<br><br><br></pre></div><!–ENDSCRIPT–><br><br>pretty much all of that came straight from the PNG manual…<br><br><!–EDIT–><span class=editedby><!–/EDIT–>[Edited by - ReKlipz on January 16, 2006 12:10:17 AM]<!–EDIT–></span><!–/EDIT–>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement