- another small bugfix for water texture loading

This commit is contained in:
Mark Vejvoda
2011-07-02 07:15:23 +00:00
parent f9ad27f655
commit 1a5c70c76e
3 changed files with 22 additions and 78 deletions

View File

@@ -258,14 +258,19 @@ Pixmap3D* PNGReader3D::read(ifstream& is, const string& path, Pixmap3D* ret) con
png_read_image(png_ptr, row_pointers);
size_t fileComponents = info_ptr->rowbytes/info_ptr->width;
size_t picComponents = (ret->getComponents()==-1)?fileComponents:ret->getComponents();
const int d = ret->getD();
const int slice = ret->getSlice();
if(ret->getPixels() == NULL){
ret->init(width,height,d, (int)picComponents);
}
//std::cout << "PNG-Components: Pic: " << picComponents << " old: " << (ret->getComponents()) << " File: " << fileComponents << std::endl;
//picComponents = 4;
//Copy image
//printf("pixmap3d loading path [%s] w = %d h = %d d = %d comp = %d\n",path.c_str(),width,height,ret->getD(),picComponents);
ret->init(width,height,ret->getD(),(int)picComponents);
uint8* pixels = ret->getPixels();
if(ret->getSlice() > 0) {
pixels = &pixels[ret->getSlice()*width*height*picComponents];
if(slice > 0) {
pixels = &pixels[slice*width*height*picComponents];
}
const size_t rowbytes = info_ptr->rowbytes;