nfengine icon indicating copy to clipboard operation
nfengine copied to clipboard

Refactor Image module in nfCommon

Open lookeypl opened this issue 10 years ago • 12 comments

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

lookeypl avatar Mar 03 '15 20:03 lookeypl

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.

Witek902 avatar Mar 04 '15 10:03 Witek902

OK, so Load must be generalized. Indeed, no need to do any extension. Updated.

lookeypl avatar Mar 04 '15 11:03 lookeypl

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)

mkulagowski avatar Jun 10 '15 10:06 mkulagowski

Sounds good.

Witek902 avatar Jun 10 '15 10:06 Witek902

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.

mkulagowski avatar Jun 22 '15 06:06 mkulagowski

Updated.

BTW. why u no Markdown when it comes to this list? ;)

lookeypl avatar Jun 22 '15 19:06 lookeypl

Please update the issue:

mkulagowski avatar Sep 07 '15 11:09 mkulagowski

Updated

lookeypl avatar Sep 07 '15 11:09 lookeypl

Please update the issue:

Please copy/paste over to issue description and specify what should actually be done:

  1. Do we really need to be able to export images from engine?
  2. Do we need to decompress BC4-BC7 (dds)?
  3. Do we need to load BC6H and BC7 (dds)?
  4. 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.

mkulagowski avatar May 27 '16 13:05 mkulagowski

  1. 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.
  2. Not for now
  3. Not for now
  4. 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.

lookeypl avatar May 27 '16 16:05 lookeypl

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

mkulagowski avatar Jun 29 '16 08:06 mkulagowski

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.

mkulagowski avatar Sep 27 '16 14:09 mkulagowski