/[libvob]/libvob/src/util/ImageLoader.cxx
ViewVC logotype

Diff of /libvob/src/util/ImageLoader.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by tjl, Sun Sep 28 13:02:18 2003 UTC revision 1.4 by tjl, Fri Oct 10 13:52:28 2003 UTC
# Line 38  namespace ImageLoader { Line 38  namespace ImageLoader {
38    
39      DBGVAR(dbg, "ImageLoader");      DBGVAR(dbg, "ImageLoader");
40    
     struct Problem {};  
   
41      /** Load an image into a raster using gdk-pixbuf.      /** Load an image into a raster using gdk-pixbuf.
42       */       */
43      RGBARaster *loadImageRGBA(const char *filename) {      RGBARaster *loadImageRGBA(const char *filename) {
44          GdkPixbuf* pb = gdk_pixbuf_new_from_file(filename);          GdkPixbuf* pb = gdk_pixbuf_new_from_file(filename);
45          if(!pb) throw Problem();          if(!pb) return 0;
46    
47          DBG(dbg) << "NC "<<gdk_pixbuf_get_n_channels(pb)          DBG(dbg) << "NC "<<gdk_pixbuf_get_n_channels(pb)
48              <<" ALP "<<gdk_pixbuf_get_has_alpha(pb)              <<" ALP "<<gdk_pixbuf_get_has_alpha(pb)
# Line 60  namespace ImageLoader { Line 58  namespace ImageLoader {
58          int w = gdk_pixbuf_get_width(pb);          int w = gdk_pixbuf_get_width(pb);
59          int h = gdk_pixbuf_get_height(pb);          int h = gdk_pixbuf_get_height(pb);
60          if(nc == 4) {          if(nc == 4) {
61                DBG(dbg) << "4: data resize\n";
62              data.resize(w*h);              data.resize(w*h);
63                DBG(dbg) << "get pixels\n";
64              GLuint *c = (GLuint *)gdk_pixbuf_get_pixels(pb);              GLuint *c = (GLuint *)gdk_pixbuf_get_pixels(pb);
65                DBG(dbg) << "pixels "<<(int)c<<"\n";
66                DBG(dbg) << "copy\n";
67              copy(c, c + w * h, data.begin());              copy(c, c + w * h, data.begin());
68              /*              /*
69              for(int i=0; i<w*h; i++)              for(int i=0; i<w*h; i++)
# Line 69  namespace ImageLoader { Line 71  namespace ImageLoader {
71              */              */
72              DBG(dbg) << "\n";              DBG(dbg) << "\n";
73          } else if(nc == 3) {          } else if(nc == 3) {
74                DBG(dbg) << "3: data resize\n";
75              data.resize(w*h);              data.resize(w*h);
76                DBG(dbg) << "get pixels\n";
77              GLubyte *c = (GLubyte *)gdk_pixbuf_get_pixels(pb);              GLubyte *c = (GLubyte *)gdk_pixbuf_get_pixels(pb);
78                DBG(dbg) << "pixels "<<(int)c<<"\n";
79              for(int i=0; i<w*h; i++) {              for(int i=0; i<w*h; i++) {
80                  data[i] = c[i*3] + (c[i*3+1] << 8) + (c[i*3+2] << 16) + (255 << 24);                  data[i] = c[i*3] + (c[i*3+1] << 8) + (c[i*3+2] << 16) + (255 << 24);
81              }              }
82                DBG(dbg) << "copied \n";
83          } else {          } else {
84              throw Problem();              DBG(dbg) << "invalid \n";
85                gdk_pixbuf_unref(pb);
86                return 0;
87          }          }
88          gdk_pixbuf_unref(pb);          gdk_pixbuf_unref(pb);
89            DBG(dbg) << "unrefed \n";
90          return new RGBARaster(w, h, data);          return new RGBARaster(w, h, data);
91      }      }
92  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26