Changeset 3095 in orxonox.OLD for orxonox/branches
- Timestamp:
- Dec 5, 2004, 2:04:17 AM (20 years ago)
- Location:
- orxonox/branches/images/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/images/importer/material.cc
r3094 r3095 554 554 pImage = (Image*)malloc(sizeof(Image)); 555 555 556 // Decode the jpeg file and fill in the image data structure to pass back 557 decodeJPG(&cinfo, pImage); 556 // DECOFING 557 // Read in the header of the jpeg file 558 jpeg_read_header(&cinfo, TRUE); 559 560 // Start to decompress the jpeg file with our compression info 561 jpeg_start_decompress(&cinfo); 562 563 // Get the image dimensions and row span to read in the pixel data 564 pImage->rowSpan = cinfo.image_width * cinfo.num_components; 565 pImage->width = cinfo.image_width; 566 pImage->height = cinfo.image_height; 567 568 // Allocate memory for the pixel buffer 569 pImage->data = new unsigned char[pImage->rowSpan * pImage->height]; 570 571 // Here we use the library's state variable cinfo.output_scanline as the 572 // loop counter, so that we don't have to keep track ourselves. 573 574 // Create an array of row pointers 575 unsigned char** rowPtr = new unsigned char*[pImage->height]; 576 for (int i = 0; i < pImage->height; i++) 577 rowPtr[i] = &(pImage->data[i*pImage->rowSpan]); 578 579 // Now comes the juice of our work, here we extract all the pixel data 580 int rowsRead = 0; 581 while (cinfo.output_scanline < cinfo.output_height) 582 { 583 // Read in the current row of pixels and increase the rowsRead count 584 rowsRead += jpeg_read_scanlines(&cinfo, &rowPtr[rowsRead], cinfo.output_height - rowsRead); 585 } 586 587 // Delete the temporary row pointers 588 delete [] rowPtr; 589 590 // Finish decompressing the data 591 jpeg_finish_decompress(&cinfo);// decodeJPG(&cinfo, pImage); 558 592 559 593 // This releases all the stored memory for reading and decoding the jpeg … … 579 613 return true; 580 614 } 581 582 void Material::decodeJPG(jpeg_decompress_struct* cinfo, Image* pImageData)583 {584 // Read in the header of the jpeg file585 jpeg_read_header(cinfo, TRUE);586 587 // Start to decompress the jpeg file with our compression info588 jpeg_start_decompress(cinfo);589 590 // Get the image dimensions and row span to read in the pixel data591 pImageData->rowSpan = cinfo->image_width * cinfo->num_components;592 pImageData->width = cinfo->image_width;593 pImageData->height = cinfo->image_height;594 595 // Allocate memory for the pixel buffer596 pImageData->data = new unsigned char[pImageData->rowSpan * pImageData->height];597 598 // Here we use the library's state variable cinfo.output_scanline as the599 // loop counter, so that we don't have to keep track ourselves.600 601 // Create an array of row pointers602 unsigned char** rowPtr = new unsigned char*[pImageData->height];603 for (int i = 0; i < pImageData->height; i++)604 rowPtr[i] = &(pImageData->data[i*pImageData->rowSpan]);605 606 // Now comes the juice of our work, here we extract all the pixel data607 int rowsRead = 0;608 while (cinfo->output_scanline < cinfo->output_height)609 {610 // Read in the current row of pixels and increase the rowsRead count611 rowsRead += jpeg_read_scanlines(cinfo, &rowPtr[rowsRead], cinfo->output_height - rowsRead);612 }613 614 // Delete the temporary row pointers615 delete [] rowPtr;616 617 // Finish decompressing the data618 jpeg_finish_decompress(cinfo);619 }620 621 622 623 615 624 616 bool Material::loadTGA(const char * tgaName, GLuint* texture) -
orxonox/branches/images/importer/material.h
r3094 r3095 95 95 96 96 bool loadJPG (char* jpgName, GLuint* texture); 97 void decodeJPG(jpeg_decompress_struct* cinfo, Image *pImageData);98 97 99 98 /// TGA ///
Note: See TracChangeset
for help on using the changeset viewer.