chriku / gimp-ktx

KTX/KTX2 image importer and exporter for gimp
BSD 3-Clause "New" or "Revised" License
8 stars 0 forks source link

Unable to import BC-Compressed KTX #1

Open flippedcracker opened 2 years ago

flippedcracker commented 2 years ago

I think I've installed this plug-in correctly. I'm able to export as KTX2. But I can't import KTX or KTX2 files, unless it's one that I've exported myself. When running install.sh, I get these results:


In file included from /usr/include/gtk-2.0/gtk/gtkobject.h:37,
                 from /usr/include/gtk-2.0/gtk/gtkwidget.h:36,
                 from /usr/include/gtk-2.0/gtk/gtkcontainer.h:35,
                 from /usr/include/gtk-2.0/gtk/gtkbin.h:35,
                 from /usr/include/gtk-2.0/gtk/gtkwindow.h:36,
                 from /usr/include/gtk-2.0/gtk/gtkdialog.h:35,
                 from /usr/include/gtk-2.0/gtk/gtkaboutdialog.h:32,
                 from /usr/include/gtk-2.0/gtk/gtk.h:33,
                 from /usr/include/gimp-2.0/libgimp/gimpui.h:22,
                 from plugin.c:8:
/usr/include/gtk-2.0/gtk/gtktypeutils.h:236:1: warning: ‘GTypeDebugFlags’ is deprecated [-Wdeprecated-declarations]
  236 | void            gtk_type_init   (GTypeDebugFlags    debug_flags);
      | ^~~~
In file included from /usr/include/glib-2.0/gobject/gobject.h:24,
                 from /usr/include/glib-2.0/gobject/gbinding.h:29,
                 from /usr/include/glib-2.0/glib-object.h:22,
                 from /usr/include/gegl-0.4/gegl.h:22,
                 from /usr/include/gimp-2.0/libgimp/gimp.h:25,
                 from plugin.c:6:
/usr/include/glib-2.0/gobject/gtype.h:698:1: note: declared here
  698 | {
      | ^
In file included from /usr/include/gtk-2.0/gtk/gtktoolitem.h:31,
                 from /usr/include/gtk-2.0/gtk/gtktoolbutton.h:30,
                 from /usr/include/gtk-2.0/gtk/gtkmenutoolbutton.h:30,
                 from /usr/include/gtk-2.0/gtk/gtk.h:126,
                 from /usr/include/gimp-2.0/libgimp/gimpui.h:22,
                 from plugin.c:8:
/usr/include/gtk-2.0/gtk/gtktooltips.h:73:3: warning: ‘GTimeVal’ is deprecated: Use 'GDateTime' instead [-Wdeprecated-declarations]
   73 |   GTimeVal last_popdown;
      |   ^~~~~~~~
In file included from /usr/include/glib-2.0/glib/galloca.h:32,
                 from /usr/include/glib-2.0/glib.h:30,
                 from /usr/include/glib-2.0/gobject/gbinding.h:28,
                 from /usr/include/glib-2.0/glib-object.h:22,
                 from /usr/include/gegl-0.4/gegl.h:22,
                 from /usr/include/gimp-2.0/libgimp/gimp.h:25,
                 from plugin.c:6:
/usr/include/glib-2.0/glib/gtypes.h:553:8: note: declared here
  553 | struct _GTimeVal
      |        ^~~~~~~~~
cp 'ktx_plugin' '/home/USER/.config/GIMP/2.10/plug-ins/ktx_plugin/'```

I see the ktx_plugin folder inthe GIMP plug-ins folder. When I try to open a .ktx file, I get the error "Cannot handle compressed texture"
chriku commented 2 years ago

libktx2 has VERY limited transcoding features and I assumed hoped I used them correctly. But I have no "compressed" texture on which I can test it on. Could you link/upload an image where it fails, so I can check if I overlooked something obvious?

flippedcracker commented 2 years ago

BackgroundImage_BACKGROUND ktx I uploaded as a .ktx.jpg because it wouldn't let me directly upload a .ktx file. Let me know if that worked.

chriku commented 2 years ago

You have sent a ktx1.1 file compressed with COMPRESSED_RGB_S3TC_DXT1_EXT. ktx1.1 is problematic anyway, so I converted it to ktx2, then the data is called BC1_RGB_UNORM_BLOCK.

libktx contains transcoding functionality to decode supercompression to RGBA32, but BC1 to RGBA32 is not supported (as the focus of libktx is purely GPUs and they can do it in hardware). This leaves me with compressed data and gimp (or more precisely babl) does not support BC1, meaning I would have to decompress the image data myself into something useful.

As I do not have time to integrate an BCx decompressor, all I can offer is to improve the error message which I will do shortly.

chriku commented 2 years ago

rewriting the plugin to use https://github.com/hglm/detex instead of libktx could solve this, but would be considerable effort

flippedcracker commented 2 years ago

Thank you for looking into it and your thorough explanation.

chriku commented 2 years ago

I will do this as soon as I have time for it