nfengine
nfengine copied to clipboard
Refactor Image module in nfCommon
Right now Image module is a one pile of code, which somehow handles multiple formats.
Things to be done:
- [x] Refactor
- [x] Reorganize the code into separate files
- [x] Write unit tests
- [ ] DDS
- [X] Write DDS BC1-BC3 decompression
- [ ] Write DDS BC4-BC7 decompression - ?
- [ ] Write DDS BC6H and BC7 load functions - ?
- [ ] Write DDS compression functions - ?
- [ ] BMP
- [x] Rewrite BMP function to load 16,24 and 32bit bmps
- [ ] Write BMP compression function - ?
- [ ] PNG
- [x] Rewrite PNG function to properly load all PNG types
- [ ] Write PNG compression function - ?
- [ ] JPG
- [ ] Write JPG compression function - ?
- [X] Write platform-independent code, if possible. If not, then separate platform-specific code and write it for both platforms
- [ ] Investigate and implement proper RGB -> Grayscale conversion
There is no point in creating classes deriving after Image to handle specific image file formats. Image class is just a container for image data in specific pixel format, divided into mipmaps, etc. You can use it without loading data from a file like BMP. Only Image::Load must take care of handling different file formats.
OK, so Load must be generalized. Indeed, no need to do any extension. Updated.
Ok...I still think that there's really big freedom of choice in here. I've changed it according to my whim. It compiles, yet I don't know anything about passing tests, as they're one of the todo's of this issue. So what do You think about this reorganization:
Image.hpp/cpp
struct ImageMipmap, class Image
ImageFormat.hpp/cpp
enum class ImageFormat and functions using it: GetTexel, SetTexel, Image::FormatToStr, Image::BitsPerPixel
ImageLoadBMP.cpp, ImageLoadPNG.cpp, ImageLoadJPG.cpp, ImageLoadDDS.cpp
everything for these functions (additional includes, defines and local functions)
Sounds good.
Ok...things have changed a bit. So let me introduce what changes have to be done right now: • Refactor and reorganize the code into separate files; • Write unit tests; • Rewrite Load function to load BMP/PNG/JPG to RBGA; • Write DDS decompression and compression functions; • Write BMP/PNG/JPG compression functions; • Rewrite BMP function to load 16,24 and 32bit bmps; • Write compression functions for BMP/PNG/JPG; • Write platform-independent code, if possible. If not, then separate platform-specific code and write it for both platforms; • Write multiple filters for mipmap generation.
Updated.
BTW. why u no Markdown when it comes to this list? ;)
Please update the issue:
- [ ] Refactor
- [ ] DDS
- [X] Write DDS BC1-BC3 decompression - DONE within refactor
- [ ] Write DDS BC4-BC7 decompression - ?
- [ ] Write DDS BC6H and BC7 load functions - TBD
- [ ] Write DDS compression functions - ?
- [ ] BMP
- [ ] Rewrite BMP function to load 16,24 and 32bit bmps - WAITING FOR REVIEW
- [ ] Write BMP compression function - ?
- [ ] PNG
- [ ] Rewrite PNG function to properly load all PNG types - WAITING FOR REVIEW
- [ ] Write PNG compression function - ?
- [ ] JPG
- [ ] Write JPG compression function - ?
- [X] Write platform-independent code, if possible. If not, then separate platform-specific code and write it for both platforms
- [ ] Investigate and implement proper RGB -> Grayscale conversion - WAITING FOR REVIEW
Updated
Please update the issue:
- [x] Refactor
- [ ] DDS
- [X] Write DDS BC1-BC3 decompression - DONE within refactor
- [ ] Write DDS BC4-BC7 decompression - ?
- [ ] Write DDS BC6H and BC7 load functions - ?
- [ ] Write DDS compression functions - ?
- [ ] BMP
- [x] Rewrite BMP function to load 16,24 and 32bit bmps
- [ ] Write BMP compression function - ?
- [ ] PNG
- [x] Rewrite PNG function to properly load all PNG types
- [ ] Write PNG compression function - ?
- [ ] JPG
- [ ] Write JPG compression function - ?
- [X] Write platform-independent code, if possible. If not, then separate platform-specific code and write it for both platforms
- [ ] Investigate and implement proper RGB -> Grayscale conversion - IN REVIEW
Please copy/paste over to issue description and specify what should actually be done:
- Do we really need to be able to export images from engine?
- Do we need to decompress BC4-BC7 (dds)?
- Do we need to load BC6H and BC7 (dds)?
- Now that I've touched any other grapics engine...do We really need those conversion functions? I understand the need to be able to import/open/load any file type we think of...but what's the use of converting it to other type? Please elaborate.
- Yes, #166 will have a ResourceManagerTool, which will use Image as well (mostly for reading/writing other formats than DDS). Additionally, Engine will have a screenshot function sometime in the future - we will make a screen shot and save it to a PNG/BMP/anything.
- Not for now
- Not for now
- As point 1, we are going to implement a ResourceManagerTool, which will load any format and convert it onto DDS used by Core. The goal of #166 is to make nfCore independent from any libjpegs, libpngs and stuffs.
It has come to my attention, that we should refactor Load() method a little bit:
Actual process - it tries loading it as every format, until it passes checks - then it proceeds further in method and loads
Expected process - it determines format at the beginning and launches appropriate load method
Grayscale conversion is done. JPG Compression is in review.
After JPG is merged, basic BMP and DDS compression will be implemented. I guess rest of the DDS tasks can be skipped and PNG compression would be made as a last one. After that, this task should be closed.