• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Post reply

Other options

Shortcuts: ALT+S save/post or ALT+P preview

Topic summary

Posted by Alen
 -  6 October 2011, 00:01:55
Great thank you  :)
Posted by Galfar
 -  5 October 2011, 13:14:47
Thanks for the link to test images.
HDR loading in Imaging is working now, I'll test it with few more exotic images and update the repository.
Saving will be done a little later.
HDR can store gamma and exposure value in the file, these are read by Imaging as well and accessible
trough the new metadata support class (though any of the PhotoShop HDRs doesn't have this defined).
Posted by Alen
 -  1 October 2011, 03:58:37
Here is a deviantart link to some nice HDR images that you can use for testing. They were made with Photoshop...

http://smashmethod.deviantart.com/art/High-Res-HDRI-Map-Pack-1-9597501
Posted by Alen
 - 26 September 2011, 23:40:05
Great, thank you  :)

I use http://qtpfsgui.sourceforge.net it can open many diffeent hdr format and has many tone mapping operator.
Posted by Galfar
 - 26 September 2011, 13:12:04
Ok I'll let you know when HDR/RGBE file format support is ready.
What software do you use for working with HDR imagery?
Posted by Alen
 - 24 September 2011, 17:48:37
oh! sorry, I didn't realize that you had a float2half function already!

If you could support HDR format instead of OpenXER, that would be perfect, all I personaly need is float colors instead of byte colors, and nothing else fancy as in xer.

Thanks again.
Posted by Galfar
 - 24 September 2011, 02:50:31
Hi, I thought of supporting OpenEXR several years ago but it seems nearly impossible: it's quite complex format and only thing that supports it
completely is OpenEXR library from ILM. Library is too big to translate it to Pascal and since it's interface is in C++ it cannot even be linked to
Pascal program (libraries in plain C can be used quite easily). One solution would be to write DLL in C++/C that will provide simple interface for Imaging.

HalfFloat image formats have been supported by Imaging for several years (if you look in ImagingFormats.pas you'll find this exact FloatToHalf
function there  ;)).

Formats that currently support floating point images in Imaging apart from Delphi only TIFF are DDS, PFM/PAM, and PSD (I'll be adding HDR/RGBE format) .

Posted by Alen
 - 21 September 2011, 21:01:34
Hello and thank you for your free software. You have put in much hard work, I know, but may I request a new file format, OpenEXR (*.exr) for reading and writing float color data for use in HDR tone mapping software. You have TIF that support float, but it doesn't seem to work in FPC. And also, maybe you can add a FloatToHalf function, such as the following...

type
  THalfFloat = type Word;

function FloatToHalf(Float: Single): THalfFloat;
const
  HalfMin:     Single = 5.96046448e-08; // Smallest positive half
  HalfMinNorm: Single = 6.10351562e-05; // Smallest positive normalized half
  HalfMax:     Single = 65504.0;        // Largest positive half
  // Smallest positive e for which half (1.0 + e) != half (1.0)
  HalfEpsilon: Single = 0.00097656;
  HalfNaN:     THalfFloat = 65535;
  HalfPosInf:  THalfFloat = 31744;
  HalfNegInf:  THalfFloat = 64512;
var
  Src: LongWord;
  Sign, Exp, Mantissa: LongInt;
begin
  Src := PLongWord(@Float)^;
  // Extract sign, exponent, and mantissa from Single number
  Sign := Src shr 31;
  Exp := LongInt((Src and $7F800000) shr 23) - 127 + 15;
  Mantissa := Src and $007FFFFF;

  if (Exp > 0) and (Exp < 30) then
  begin
    // Simple case - round the significand and combine it with the sign and exponent
    Result := (Sign shl 15) or (Exp shl 10) or ((Mantissa + $00001000) shr 13);
  end
  else if Src = 0 then
  begin
    // Input float is zero - return zero
    Result := 0;
  end
  else
  begin
    // Difficult case - lengthy conversion
    if Exp <= 0 then
    begin
      if Exp < -10 then
      begin
        // Input float's value is less than HalfMin, return zero
         Result := 0;
      end
      else
      begin
        // Float is a normalized Single whose magnitude is less than HalfNormMin.
        // We convert it to denormalized half.
        Mantissa := (Mantissa or $00800000) shr (1 - Exp);
        // Round to nearest
        if (Mantissa and $00001000) > 0 then
          Mantissa := Mantissa + $00002000;
        // Assemble Sign and Mantissa (Exp is zero to get denormalized number)
        Result := (Sign shl 15) or (Mantissa shr 13);
      end;
    end
    else if Exp = 255 - 127 + 15 then
    begin
      if Mantissa = 0 then
      begin
        // Input float is infinity, create infinity half with original sign
        Result := (Sign shl 15) or $7C00;
      end
      else
      begin
        // Input float is NaN, create half NaN with original sign and mantissa
        Result := (Sign shl 15) or $7C00 or (Mantissa shr 13);
      end;
    end
    else
    begin
      // Exp is > 0 so input float is normalized Single

      // Round to nearest
      if (Mantissa and $00001000) > 0 then
      begin
        Mantissa := Mantissa + $00002000;
        if (Mantissa and $00800000) > 0 then
        begin
          Mantissa := 0;
          Exp := Exp + 1;
        end;
      end;

      if Exp > 30 then
      begin
        // Exponent overflow - return infinity half
        Result := (Sign shl 15) or $7C00;
      end
      else
        // Assemble normalized half
        Result := (Sign shl 15) or (Exp shl 10) or (Mantissa shr 13);
    end;
  end;
end;


Thanks.
SMF spam blocked by CleanTalk