void AddFeature(string filename, int featurenumber) { Directory.CreateDirectory("cache"); string cachefilename = Path.GetFileNameWithoutExtension(filename).ToLower() + ".jpg"; string cachefilepath = Path.Combine("cache", cachefilename); LogFile.GetInstance().WriteLine(cachefilepath); if (!File.Exists(cachefilepath)) { byte[] unitpicbytes = new UnitPicCreator().CreateUnitPic(filename, picturewidth, pictureheight); Image image = new Image(picturewidth, pictureheight); //System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(picturewidth, pictureheight); for (int x = 0; x < picturewidth; x++) { for (int y = 0; y < pictureheight; y++) { image.SetPixel(x, pictureheight - y - 1, unitpicbytes[y * picturewidth * 4 + x * 4 + 0], unitpicbytes[y * picturewidth * 4 + x * 4 + 1], unitpicbytes[y * picturewidth * 4 + x * 4 + 2], 255 ); } } image.Save(cachefilepath); //DevIL.DevIL.SaveBitmap(cachefilepath, bitmap); } // writing direct to pixbuf sortof works but gives corruption //Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(unitpicbytes, true, 8, picturewidth, pictureheight, picturewidth * 4, new Gdk.PixbufDestroyNotify(pixbufdestroynotify)); // Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(unitpicbytes, true, 8, picturewidth, pictureheight, picturewidth * 4, null); //Image newimage = new Image(pixbuf); Gtk.Image newimage = new Gtk.Image(Path.Combine("cache", cachefilename)); string unitname = Path.GetFileNameWithoutExtension(filename).ToLower(); Label label = new Label(unitname); VBox vbox = new VBox(false, 0); vbox.PackStart(newimage); vbox.PackEnd(label); Button newbutton = new Button(vbox); buttons.Add(newbutton); newbutton.Name = unitname; newbutton.Clicked += new EventHandler(buttonpressed); Unhighlight(newbutton); featuretable.Attach(newbutton, 0, 1, (uint)featurenumber - 1, (uint)featurenumber); featuretable.ShowAll(); }