| 539 | | |
| | 539 | #if 1 |
| | 540 | osg::ref_ptr<osg::Image> originalImage = osgDB::readImageFile("Images/dog_left_eye.jpg"); |
| | 541 | |
| | 542 | osg::ref_ptr<osg::Image> subImage = new osg::Image; |
| | 543 | subImage->setUserData(originalImage.get()); // attach the originalImage as user data to prevent it being deleted. |
| | 544 | |
| | 545 | // now assign the appropriate portion data from the originalImage |
| | 546 | subImage->setImage(originalImage->s()/2, originalImage->t()/2, originalImage->r(), // half the width and height |
| | 547 | originalImage->getInternalTextureFormat(), // same internal texture format |
| | 548 | originalImage->getPixelFormat(),originalImage->getDataType(), // same pixel foramt and data type |
| | 549 | originalImage->data(originalImage->s()/4,originalImage->t()/4), // offset teh start point to 1/4 into the image |
| | 550 | osg::Image::NO_DELETE, // don't attempt to delete the image data, leave this to the originalImage |
| | 551 | originalImage->getPacking(), // use the the same packing |
| | 552 | originalImage->s()); // use the width of the original image as the row width |
| | 553 | |
| | 554 | |
| | 555 | subImage->setPixelBufferObject(new osg::PixelBufferObject(subImage.get())); |
| | 556 | |
| | 557 | #if 0 |
| | 558 | OSG_NOTICE<<"orignalImage iterator"<<std::endl; |
| | 559 | for(osg::Image::DataIterator itr(originalImage.get()); itr.valid(); ++itr) |
| | 560 | { |
| | 561 | OSG_NOTICE<<" "<<(void*)itr.data()<<", "<<itr.size()<<std::endl; |
| | 562 | } |
| | 563 | |
| | 564 | OSG_NOTICE<<"subImage iterator, size "<<subImage->s()<<", "<<subImage->t()<<std::endl; |
| | 565 | unsigned int i=0; |
| | 566 | for(osg::Image::DataIterator itr(subImage.get()); itr.valid(); ++itr, ++i) |
| | 567 | { |
| | 568 | OSG_NOTICE<<" "<<i<<", "<<(void*)itr.data()<<", "<<itr.size()<<std::endl; |
| | 569 | |
| | 570 | for(unsigned char* d=const_cast<unsigned char*>(itr.data()); d<(itr.data()+itr.size()); ++d) |
| | 571 | { |
| | 572 | *d = 255-*d; |
| | 573 | } |
| | 574 | } |
| | 575 | #endif |
| | 576 | |
| | 577 | |
| | 578 | _imageList.push_back(subImage.get()); |
| | 579 | |
| | 580 | #else |