+ storage(storage_pixelformat_from_graphics(img.get_format()), w, h, d);
+ else if(w!=width || h!=height || d!=depth)
+ throw incompatible_data("Texture3D::load_image");
+
+ PixelStore pstore = PixelStore::from_image(img);
+ BindRestore _bind_ps(pstore);
+
+ image(0, fmt, UNSIGNED_BYTE, img.get_data());
+}
+
+void Texture3D::image(const Graphics::Image &img, unsigned lv, bool srgb)
+{
+ unsigned w = img.get_width();
+ unsigned h = img.get_height();
+ unsigned d = 1;
+
+ if(depth)
+ {
+ if(h%depth)
+ throw incompatible_data("Texture3D::load_image");
+ h /= depth;
+ d = depth;
+ }
+ else
+ {
+ if(h%w)
+ throw incompatible_data("Texture3D::load_image");
+ d = h/w;
+ h = w;
+ }
+
+ PixelFormat fmt = pixelformat_from_graphics(img.get_format());
+ if(width==0)
+ {
+ unsigned l = (is_mipmapped(min_filter) ? lv : 1);
+ storage(storage_pixelformat_from_graphics(img.get_format(), srgb), w, h, d, l);
+ }