Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TGA: incorrect display of some files #26

Closed
Krakean opened this issue Mar 10, 2019 · 10 comments
Closed

TGA: incorrect display of some files #26

Krakean opened this issue Mar 10, 2019 · 10 comments

Comments

@Krakean
Copy link

Krakean commented Mar 10, 2019

@nickbabcock
https://nofile.io/f/Sz8BehO058W/pfimtgabadcases.zip
Those files mostly TGASharpLib examples, so all of these files you can put to Pfim.Tests\data for regression tests in future. All of these files works fine in Paint.NET & ImageGlass (good image viewer, written in C#, opensource on github) & Imagine (images viewer plugin for Total Commander)

  1. CCM8.tga - incorrect display (https://i.imgur.com/sqVbzYl.png), you have this one in Pfim.Tests\data
  2. CTC32.tga - cannot be displayed at all
  3. DSCN1910_24bpp_uncompressed_01.tga - exception (method is not implemented)
  4. DSCN1910_24bpp_uncompressed_10.tga - displayed incorrectly (https://i.imgur.com/4h8xEur.jpg)
  5. flag_b32.tga and flag_t32.tga - cannot be displayed at all, last one you also have in Pfim.Tests\data
  6. rgb24_top_left_colormap.tga - displayed incorrectly (https://i.imgur.com/tzYNtZa.png, background color seems like incorrect)
  7. rgb32_top_left_rle_colormap.tga - exception (method is not implemented, different from 3)
  8. Tree_NoAlphaBits.tga - exception (same as 7)
  9. UCM8.tga - same as 1, color channels displayed incorrectly
  10. UTC32.TGA - cannot be displayed at all.
@nickbabcock
Copy link
Owner

For the images that aren't displayed: it's because they are transparent: paint.net, imageglass, and pfim are in agreement on this.

Some of the incorrectly displayed images appear different in each program, so I'll need to dive into those.

@nickbabcock
Copy link
Owner

I hope to implement decoding for DSCN1910_24bpp_uncompressed_01.tga this week. I've taken care of all the rest. Then I'll release a patch update

@Krakean
Copy link
Author

Krakean commented Mar 18, 2019

@nickbabcock glad to hear. hopefully next you switch to dds.

@Krakean
Copy link
Author

Krakean commented Mar 27, 2019

I hope to implement decoding for DSCN1910_24bpp_uncompressed_01.tga this week.

@nickbabcock how is progress on this, Nick? :)

@nickbabcock
Copy link
Owner

I hope to implement decoding for DSCN1910_24bpp_uncompressed_01.tga this week.

I should not have written that while on holiday 😄

The hardest part of that test case is finding an image that isn't large, as I am starting to notice the repo size growing on a slow internet connection. I think I found a way by bit flipping the orientation in the header of a small image.

@nickbabcock
Copy link
Owner

Pfim 0.6.0 has been released with this bugfix, thank you for the report.

DSCN1910_24bpp_uncompressed_01.tga is decoded differently depending on the program, but I've created a new issue (#38) to track that further.

@Krakean
Copy link
Author

Krakean commented Mar 30, 2019

@nickbabcock congrats with release :)
Now its time to DDS BC6H/BC7 get some attention? :)

@nickbabcock
Copy link
Owner

Now its time to DDS BC6H/BC7 get some attention? :)

Haha yeah, I need to figure out a game plan for how I want to tackle it, as it hasn't gotten any easier in the meantime. 😆

@Krakean
Copy link
Author

Krakean commented Mar 31, 2019

@nickbabcock

I need to figure out a game plan for how I want to tackle it

Let me try to help you a bit :)
First of all, you need easy to use tool to get BC6H/BC7 files. There is two popular choices - AMD Compressonator (https://github.com/GPUOpen-Tools/Compressonator) and DirectXTex tools (https://github.com/Microsoft/DirectXTex/wiki), last one seems much easier to me.
You can download Texconv utility from DirectXTex releases section (there is also handy one - texdiag utility, to display extended info about image for example), and use this command line to get BC7 files for example:
texconv -dx10 -y -ft DDS -f BC7_UNORM -o C:\path\where\to\save C:\path\to\source\image.tga
You will get image.dds file in result.
Then, you need reference viewer. DdsView from DirectXTex is good to go. Usage is simple: ddsview.exe C:\path\to\dds\file.dds
If you won't download DirectXTex and compile DdsView by yourself, here is compiled from latest master for you - https://nofile.io/f/8RNaV0hfF06/DDSView.exe
A few already made samples for you - https://nofile.io/f/quWjeAr4xh4/BC6-7-samples.rar (they made using true-24.tga from your Tests images folder, but guess for BC6 need to use source image with alpha because BC6 is all about alpha after all, and BC7.dds is separated image with a motocycle found somewhere on the internet)

Second, reference library to start with. :)
Well, I guess its always best to start with DirectXTex's BC6/7 as reference source, but its in C++.
In case of C#, despite the fact I advised you here at least three libraries already, my suggestion to start with https://github.com/KFreon/CSharpImageLibrary (once you compile it, you will have UI_Project.exe as demo application, also take attention on small note below), BC6/7 code of this library is adapted from BC6/7 DirectXTex (sadly author not noted which revision of DirectXTex he used)
Its abandoned, but its working (tested on BC7.dds from samples archive above):
https://i.imgur.com/kwbNOKt.png (here you can see UI bug - BC7 bike image loaded, but UI consider that its still loading, not sure on which side bug is - on library side, or on UI demo side, but anyway we got image), it also load fine (though, with the same UI bug which is not seen if you feed DXT5 for example) BC6H_UF16.dds (https://i.imgur.com/5Wq5VtB.png), though it cannot load BC6H_SF16.dds, but still its better than nothing :)

** - small note about compiling. Its cannot resolve UsefulThings package, so just open 'Manage Nuget Package', uninstall UsefulCsharpThings package, and just type it in 'Browse' and install again.

@Krakean
Copy link
Author

Krakean commented Mar 31, 2019

@nickbabcock

Made a few changes to CSharpImageLibrary, may be it will help you just a bit:
https://nofile.io/f/oMfpVdSXqT5/CSharpImageLibrary.zip
a. Should compile fine, with UsefuLCsharpThings package included.
b. Fixed (https://i.imgur.com/jg9jGDc.png) "Loading" UI bug as seen in my screenshots above, author incorrectly disabled preview generation for BC6/7 dds files :)
c. Removed all save-related & encoders methods for DDS files, since Pfim is just decoding library and thus you interested only in decoding, not in encoding DDS files :) DDS code went from 260kb to 159kb as result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants