Browse Source

fix crash on 16-bit component textures

David Rose 22 years ago
parent
commit
7032f7548e
1 changed files with 4 additions and 1 deletions
  1. 4 1
      panda/src/gobj/pixelBuffer.cxx

+ 4 - 1
panda/src/gobj/pixelBuffer.cxx

@@ -236,6 +236,7 @@ bool PixelBuffer::load(const PNMImage& pnmimage)
   _xsize = pnmimage.get_x_size();
   _xsize = pnmimage.get_x_size();
   _ysize = pnmimage.get_y_size();
   _ysize = pnmimage.get_y_size();
   _num_components = num_components;
   _num_components = num_components;
+  _component_width = 1;
   _loaded = true;
   _loaded = true;
 
 
   // Now copy the pixel data from the PNMImage into our internal
   // Now copy the pixel data from the PNMImage into our internal
@@ -270,7 +271,8 @@ bool PixelBuffer::load(const PNMImage& pnmimage)
     // Another possible case: two bytes per pixel, and the source
     // Another possible case: two bytes per pixel, and the source
     // image shows a maxval of 65535.  Again, no scaling is necessary.
     // image shows a maxval of 65535.  Again, no scaling is necessary.
     _type = T_unsigned_short;
     _type = T_unsigned_short;
-//    _image = PTA_uchar::empty_array(_xsize * _ysize * _num_components * 2);
+    _image = PTA_uchar::empty_array(_xsize * _ysize * _num_components * 2);
+    _component_width = 2;
     int idx = 0;
     int idx = 0;
     
     
     for (int j = _ysize-1; j >= 0; j--) {
     for (int j = _ysize-1; j >= 0; j--) {
@@ -318,6 +320,7 @@ bool PixelBuffer::load(const PNMImage& pnmimage)
     // values.
     // values.
     _type = T_unsigned_short;
     _type = T_unsigned_short;
     _image = PTA_uchar::empty_array(_xsize * _ysize * _num_components * 2);
     _image = PTA_uchar::empty_array(_xsize * _ysize * _num_components * 2);
+    _component_width = 2;
     int idx = 0;
     int idx = 0;
     double scale = 65535.0 / (double)maxval;
     double scale = 65535.0 / (double)maxval;