Skip to content

Releases: nickbabcock/Pfim

0.8.0 - September 5th 2019

12 Nov 23:22
Compare
Choose a tag to compare

Two big changes: netstandard 2.0 targeting and DDS mipmap support.

With a bump to netstandard 2.0, Pfim is able to slim down dependencies and the amount of code that is conditionally compiled. The only platforms that lose out here are platforms that are EOL or nearing EOL.

Each image file may contain several images in addition to the main image decoded. There are pre-calculated / optimized for smaller dimensions -- often called mipmaps. Previously there was no way to access these images until now.

New property under IImage

MipMapOffset[] MipMaps { get; }

With MipMapOffset defined with properties:

public int Stride { get; }
public int Width { get; }
public int Height { get; }
public int DataOffset { get; }
public int DataLen { get; }

These should look familiar to known IImage properties, the one exception being DataOffset. This is the offset that the mipmap data starts in IImage.Data. To see usage, here is a snippet for WPF to split an IImage into separate images by mipmaps

private IEnumerable<BitmapSource> WpfImage(IImage image)
{
    var pinnedArray = GCHandle.Alloc(image.Data, GCHandleType.Pinned);
    var addr = pinnedArray.AddrOfPinnedObject();
    var bsource = BitmapSource.Create(image.Width, image.Height, 96.0, 96.0, 
        PixelFormat(image), null, addr, image.DataLen, image.Stride);

    handles.Add(pinnedArray);
    yield return bsource;

    foreach (var mip in image.MipMaps)
    {
        var mipAddr = addr + mip.DataOffset;
        var mipSource = BitmapSource.Create(mip.Width, mip.Height, 96.0, 96.0,
            PixelFormat(image), null, mipAddr, mip.DataLen, mip.Stride);
        yield return mipSource;
    }
}

Example image:

image

Only additional images are stored in MipMaps (the base image is excluded).

This continues the work in 0.7.0 were users should start relying on the DataLen property and not Data.Length as now multiple images share this buffer

0.7.0 - April 27th, 2019

28 Apr 00:38
Compare
Choose a tag to compare
  • Added: Pfim.FromStream to decode tga or dds image from a stream. Pfim will heuristically determine what image based on the header.
  • Added: IImageAllocator that will allow one to pool intermediate byte buffers as well as the resulting data buffer. This is to reduce memory usage and GC pressure. Benchmarks have naive pooling implementations showing up to a 3x performance improvement. Set a custom allocator through PfimConfig
  • Changed: Targa color maps are applied by default (so no need to write IImage::ApplyColorMap every time). If this behavior is not desired, one can set applyColorMap to false in PfimConfig.
  • Changed: IImage implements IDisposable (so that the allocator can reclaim the data buffer). While disposing an image is only necessary when a custom allocator is supplied, the best practice is to still dispose an image:
using (var image = Pfim.FromFile(file)) { }
  • Changed: Pfim.FromFile no longer determines the image type by file extension. Instead it will heuristically determine the image type based on the file header.
  • Changed: Exception thrown on invalid targa image types (3rd byte in the header)

0.6.0 - March 28th 2019

29 Mar 00:36
Compare
Choose a tag to compare
  • Added: IImage::ApplyColorMap, which will apply a colormap to the image, overwriting previous data and metadata like format, stride, pixel depth, etc. An example of a colormap is when an image only uses 256 colors. Instead of consuming 32 bits per pixel on disk, the image data instead will consist of 8 bit indices into the colormap located in the header of an image.
  • Support Targa images orientated in the top left corner.
  • Targa images encoded in the top right or bottom right corners (two extremely rare formats) fallback to bottom left corner decoding.
  • Fix errors or incorrect decoding of dds images with widths and heights that aren't divisible by their block size.
  • Fix MipMapCount misspelling in DdsHeader

0.5.2 - August 2nd 2018

02 Aug 22:17
Compare
Choose a tag to compare
  • Include Mipmap data as part of IImage::Data for DDS images that skipped decoding
  • Recognize and decode ATI2 dds images

0.5.1 - May 8th 2018

09 May 01:45
Compare
Choose a tag to compare
  • Expose BitsPerPixel in IImage
  • Add configuration to the decoding process via PfimConfig:
    • Configurable buffer size for chunk decoding
    • Allow opt-out of DDS BC decompression to allow for GPU offload.
  • Optimize fast path for decoding byte[] data
  • Latency of decoding BC DDS images decreased by 10%
  • Highly experimental decoding of DX10 images.

0.5.0 - March 18th 2018

18 Mar 14:29
Compare
Choose a tag to compare
  • Support for 24bit rgb dds images
  • Support for additional 16bit dds images
    • Rgba16 (each channel is 4 bits)
    • R5g5b5a1
    • R5g6b5
    • R5g5b5
  • Bug fixes for currently supported dds images
  • Initial implementation for interpreting tga color maps
  • Support for 16bit R5g5b5 tga images
  • Support for 8bit tga images
  • Fix bad calculation of tga strides

0.4.4 - October 31st 2017

31 Oct 23:17
Compare
Choose a tag to compare
  • Fix red and blue color swap for TopLeft encoded targa images
  • 20x performance improvement for TopLeft encoded targa images

0.4.3 - October 31st 2017

31 Oct 21:11
Compare
Choose a tag to compare
  • Fix infinite loop on certain large targa and dds images

0.4.2 - October 10th 2017

10 Oct 21:09
Compare
Choose a tag to compare
  • Release .NET Standard 1.0 version that doesn't contain File IO

0.4.1 - October 9th 2017

09 Oct 22:18
Compare
Choose a tag to compare
  • Fix decoding of non-square uncompressed targa images
  • Fix edge case decoding for compressed targa images