ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 ImageEn 6.0.1 and 64-bit raw image loading issue
 New Topic  Reply to Topic
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

mhieta

Finland
78 Posts

Posted - May 27 2015 :  08:47:42  Show Profile  Reply
Hi,

I'm using ImageEn 6.0.1 in XE8 and trying to compile my app to 64-bit.
I have this kind of code to load thumbnails:
function SpMakeThumbFromFileImageEn(Filename: WideString; OutBitmap: TBitmap;
  ThumbW, ThumbH: Integer; BgColor: TColor; Subsampling, ExifThumbnail, ExifOrientation: Boolean;
  var ImageWidth, ImageHeight: Integer): Boolean;
var
  AttachedIEBitmap: TIEBitmap;
  ImageEnIO: TImageEnIO;
  ImageEnProc: TImageEnProc;
  TempBitmap: TBitmap;
  F: TVirtualFileStream;
  DestR: TRect;
  Ext: string;
  IsRaw, IsVideo: Boolean;
  Orientation: Integer;
  dcraw: THandle;
begin
  Result := False;
  ImageWidth := 0;
  ImageHeight := 0;
  Orientation := 0;
  {$IFDEF WIN32}
  dcraw := GetModuleHandle('dcrawlib.dll');
  {$ENDIF}
  {$IFDEF WIN64}
  dcraw := GetModuleHandle('ielib64.dll'); // Is this correct or do I need something else to load raw images correctly.
  {$ENDIF}
  if not Assigned(OutBitmap) then Exit;
  Ext := WideLowerCase(WideExtractFileExt(Filename));

  IsRaw := (ext = '.crw') or (ext = '.cr2') or (ext = '.dng')
        or (ext = '.nef') or (ext = '.raw') or (ext = '.raf')
        or (ext = '.x3f') or (ext = '.orf') or (ext = '.srf')
        or (ext = '.mrw') or (ext = '.dcr') or (ext = '.bay')
        or (ext = '.pef') or (ext = '.sr2') or (ext = '.arw')
        or (ext = '.kdc') or (ext = '.mef') or (ext = '.3fr')
        or (ext = '.k25') or (ext = '.erf') or (ext = '.cam')
        or (ext = '.cs1') or (ext = '.dc2') or (ext = '.dcs')
        or (ext = '.fff') or (ext = '.mdc') or (ext = '.mos')
        or (ext = '.nrw') or (ext = '.ptx') or (ext = '.pxn')
        or (ext = '.rdc') or (ext = '.rw2') or (ext = '.rwl')
        or (ext = '.iiq') or (ext = '.srw');

  IsVideo := (ext = '.avi') or (ext = '.mpg') or (ext = '.mpeg') or (ext = '.wmv');

  TempBitmap := TBitmap.Create;
  TempBitmap.Canvas.Lock;
  try
    AttachedIEBitmap := TIEBitmap.Create;
    ImageEnIO := TImageEnIO.Create(nil);
    ImageEnProc := TImageEnProc.Create(Nil);
    try
      ImageEnIO.AttachedIEBitmap := AttachedIEBitmap;
      ImageEnProc.AttachedIEBitmap := AttachedIEBitmap;
      ImageEnIO.Params.Width := ThumbW;
      ImageEnIO.Params.Height := ThumbH;
      ImageEnIO.Params.JPEG_Scale := ioJPEG_AUTOCALC;
      ImageEnIO.Params.JPEG_DCTMethod := ioJPEG_IFAST;
      if (dcraw <> 0) then
        // Automatically adjust orientation of all files that contain EXIF info
        ImageEnIO.Params.EnableAdjustOrientation := ExifOrientation;
      // ImageEn bug: TImageEnIO.LoadFromStream doesn't work with wmf/emf/sun files
      if (Ext = '.wmf') or (Ext = '.emf') or (Ext = '.sun') then
      begin
        ImageEnIO.LoadFromFile(Filename);
        ImageWidth := ImageEnIO.Params.Width;
        ImageHeight := ImageEnIO.Params.Height;
        AttachedIEBitmap.CopyToTBitmap(TempBitmap);
      end;
      if IsVideo then
      begin
        ImageEnIO.OpenMediaFile(Filename);
        ImageEnIO.LoadFromMediaFile(5);
        ImageWidth := ImageEnIO.Params.Width;
        ImageHeight := ImageEnIO.Params.Height;
        AttachedIEBitmap.CopyToTBitmap(TempBitmap);
        ImageEnIO.CloseMediaFile;
      end
      else
      begin
        F := TVirtualFileStream.Create(Filename, fmOpenRead or fmShareDenyNone);
        try
          // If dcrawlib.dll is used
          if IsRaw AND (dcraw <> 0) then
          begin
            ImageEnIO.Params.RAW_GetExifThumbnail := False;
            // Do not load small thumbnails from file. They usually have black borders.
            // Use the large size EXIF preview images instead, if they are available.
            ImageEnIO.Params.RAW_ExtraParams := '-e';
            // ImageEnBug: LoadFromStream doesn't work well on RAW files,
            // it doesn't load the Exif thumbnails, use LoadFromStreamRAW instead
            ImageEnIO.LoadFromStreamRAW(F);
            // If no large size EXIF preview images are embedded, use the small thumbs instead
            if (AttachedIEBitmap.Width = 0) OR (AttachedIEBitmap.Height = 0) then
            begin
              ImageEnIO.Params.RAW_GetExifThumbnail := True;
              ImageEnIO.Params.RAW_ExtraParams := '';
              ImageEnIO.LoadFromStreamRAW(F);
            end;
            if ExifOrientation then
              if (ext = '.crw') then
                Orientation := GetCrwOrientation(F) // CRW doesn't have Exif, read the CIFF data
              else
                Orientation := ImageEnIO.Params.EXIF_Orientation;
            if (Orientation = 6) or (Orientation = 8) then
              IEAdjustEXIFOrientation(AttachedIEBitmap, Orientation);
            ImageWidth := AttachedIEBitmap.Width;
            ImageHeight := AttachedIEBitmap.Height;
          end
          else
          // If dcrawlib.dll is not used
          if IsRaw AND (dcraw = 0) then
          begin
            ImageEnIO.Params.RAW_GetExifThumbnail := True;
            ImageEnIO.LoadFromStreamRAW(F);
            if ExifOrientation then
              if (ext = '.crw') then
                Orientation := GetCrwOrientation(F) // CRW doesn't have Exif, read the CIFF data
              else
                Orientation := ImageEnIO.Params.EXIF_Orientation;
            if (Orientation = 6) or (Orientation = 8) then
              IEAdjustEXIFOrientation(AttachedIEBitmap, Orientation);
            ImageWidth := AttachedIEBitmap.Width;
            ImageHeight := AttachedIEBitmap.Height;
          end
          else
          // If it's not a digital camera RAW file
          begin
            ImageEnIO.Params.EnableAdjustOrientation := ExifOrientation;
            ImageEnIO.Params.GetThumbnail := ExifThumbnail;
            ImageEnIO.LoadFromStream(F);
            if ImageEnIO.Params.JPEG_Scale_Used > 1 then
            begin
              ImageWidth := AttachedIEBitmap.Width;
              ImageHeight := AttachedIEBitmap.Height;
            end
            else
            begin
              ImageWidth := ImageEnIO.Params.Width;
              ImageHeight := ImageEnIO.Params.Height;
            end;
          end;
          AttachedIEBitmap.CopyToTBitmap(TempBitmap);
        finally
          F.Free;
        end;
      end;
    finally
      ImageEnIO.Free;
      ImageEnProc.Free;
      AttachedIEBitmap.Free;
    end;
    // Resize the thumb
    // Need to lock/unlock the canvas here
    OutBitmap.Canvas.Lock;
    try
      DestR := SpRectAspectRatio(ImageWidth, ImageHeight, ThumbW, ThumbH, talNone, True);
      SpInitBitmap(OutBitmap, DestR.Right, DestR.Bottom, BgColor);
      // StretchDraw is NOT THREADSAFE!!! Use SpStretchDraw instead
      SpStretchDraw(TempBitmap, OutBitmap.Canvas, DestR, Subsampling);
      Result := True;
    finally
      OutBitmap.Canvas.UnLock;
    end;
    Result := True;
  finally
    TempBitmap.Canvas.Unlock;
    TempBitmap.Free;
  end;
end;


And yes I have ielib64.dll in same folder where is compiled exe file. But still I cannot load and display raw images.

Also this is my ie.inc:
{.$undef IEUSEASM}

// See documentation regarding use of IELIB DLL in 32bit applications
{.$define IEUSEDLLJPEGLIB}
{.$define IEUSEDLLPNGLIB}
{.$define IEUSEDLLJPEG2000LIB}
{.$define IEUSEDLLRAWLIB}

{$ifdef WIN64}
  {$undef IEUSEASM}
  {$define IEUSEDLLJPEGLIB}     // Use DLL Jpeg library (otherwise use linked jpeg library)
  {$define IEUSEDLLPNGLIB}      // Use DLL PNG library (otherwise use linked png library)
  {$define IEUSEDLLJPEG2000LIB} // Use DLL Jpeg2000 (Jasper) library (otherwise use linked jasper library)
  {$define IEUSEDLLRAWLIB}      // Use DLL RAW library (otherwise use embedded RAW library)
  {$undef IEUSEDESIGNINTF}
  {$undef IEUSEFILTEDIT}
  {$undef IEREGISTERPROPERTYEDITOR}
{$endif}


- Marko

Uwe

284 Posts

Posted - May 27 2015 :  17:48:39  Show Profile  Reply
Marko, does

ImageEnIO.Params.RAW_ExtraParams := '-e';

actually work when you use ielib64.dll?


-Uwe
Go to Top of Page

mhieta

Finland
78 Posts

Posted - May 27 2015 :  23:27:18  Show Profile  Reply
Hi,

Uwe, Well. I don't know. :)

I have only modified that function to:
{$IFDEF WIN32}
  dcraw := GetModuleHandle('dcrawlib.dll');
  {$ENDIF}
  {$IFDEF WIN64}
  dcraw := GetModuleHandle('ielib64.dll'); // Is this correct or do I need something else to load raw images correctly.
  {$ENDIF}


I also want to know does those RAW_ExtraParams work with ielib64.dll?

This conversion 32-bit to 64-bit would be easier if there were dcrawlib64.dll available.

- Marko
Go to Top of Page

Uwe

284 Posts

Posted - May 28 2015 :  09:43:12  Show Profile  Reply
Marko, did you call

IELibAvailable()

to initialize the ielib64 library on program start?

-Uwe
Go to Top of Page

mhieta

Finland
78 Posts

Posted - May 28 2015 :  10:56:17  Show Profile  Reply
Hi,

Nope. I have not done that. Trying now..

I have this in FormShow:

{$IFDEF WIN64}
  IELibAvailable();
  {$ENDIF}
  {$IFDEF WIN32}
  if Fileexists(PChar(ExtractFilePath(ParamStr(0)) + '\' + 'dcrawlib.dll')) then
  begin
    IEFileFormatRemove(ioRAW); // disables internal RAW support
    IEAddExtIOPlugIn(ExtractFilePath(ParamStr(0)) + '\' + 'dcrawlib.dll');
  end;
  {$ENDIF}


And it doesn't help. Still I don't see any raw images loaded.

- Marko
Go to Top of Page

mhieta

Finland
78 Posts

Posted - May 28 2015 :  11:12:51  Show Profile  Reply
Hi,

It seems that -e parameter is not supported by ielib64.dll.
Cause with Process Explorer I don't see it.






Edit:
Trying now:
{$IFDEF WIN32}
ImageEnIO.Params.RAW_ExtraParams := '-e';
{$ENDIF}
{$IFDEF WIN64}
ImageEnIO.Params.RAW_ExtraParams := '-h';
{$ENDIF}


This work for some raw images. But not all. Still major part raw images is not loaded. Those same raw images gets loaded with that dcrawlib.dll fine.


- Marko
Go to Top of Page

mhieta

Finland
78 Posts

Posted - May 28 2015 :  11:25:34  Show Profile  Reply
Hi,

Can we get the same raw lib embedded in to ielib64 what is included in dcrawlib.dll?

- Marko
Go to Top of Page

Uwe

284 Posts

Posted - May 28 2015 :  12:52:48  Show Profile  Reply
That doesn't look too good. Now I remember why I was opposed to the solution to combine several libraries into a (somewhat) closed source ielib64.dll when it was introduced. Sorry Marko, I'm out of ideas here.

-Uwe


PS: If you would like a 64bit dcrawlib.dll, create a feature request and vote for it. I thought there had been such a request in the past already, but it seems it was deleted.
Go to Top of Page

mhieta

Finland
78 Posts

Posted - May 28 2015 :  14:09:25  Show Profile  Reply
Hi,

Yes, I will create feature request tomorrow. Thanks Uwe.

Anyway I'm going to continue to port my other apps to 64-bit and hopefully soon this raw-lib will get updated, if not I cannot release 64-bit version :(

- Marko
Go to Top of Page

xequte

38510 Posts

Posted - May 29 2015 :  04:20:49  Show Profile  Reply
Hi

The ielib64.dll already includes dcrawlib, so there is no need for a separate raw dll for 64bit applications.

Also, note that Image will automatically pass -e to ielib/dcrawlib a thumbnail is requested (if an EXIF thumbnail is not available).


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Uwe

284 Posts

Posted - May 29 2015 :  09:51:06  Show Profile  Reply
Nigel,

So ImageEnIO.Params.RAW_GetExifThumbnail calls -e ? That can't be right. Doesn't RAW_GetExifThumbnail extract the small embedded EXIF thumbnail (if there is one) while '-e' opens the embedded JPEG preview image instead of the full size camera RAW image?

-Uwe
Go to Top of Page

mhieta

Finland
78 Posts

Posted - May 29 2015 :  10:38:19  Show Profile  Reply
Hi,

I have now this code:

{$IFDEF WIN32}
ImageEnIO.Params.RAW_GetExifThumbnail := False;
// Do not load small thumbnails from file. They usually have black borders.
// Use the large size EXIF preview images instead, if they are available.
ImageEnIO.Params.RAW_ExtraParams := '-e';
{$ENDIF}
{$IFDEF WIN64}
ImageEnIO.Params.RAW_GetExifThumbnail := True;
{$ENDIF}


But still with ielib64.dll it doesn't display all thumbnails what it can display with dcrawlib.

Here is few sample images what have problems to load:
http://koti.mbnet.fi/mhieta/temp/178H0047a.dng
http://koti.mbnet.fi/mhieta/temp/CRW_4794.dng
http://koti.mbnet.fi/mhieta/temp/_DSC0213.ARW

- Marko
Go to Top of Page

xequte

38510 Posts

Posted - May 30 2015 :  22:07:39  Show Profile  Reply
Sorry Uwe, I did not describe that adequately.

If GetThumbnail is enabled then ImageEn tries to retrieve an EXIF JPEG thumbnail, if that is not available then it falls back to using "-e" to retrieve the preview image.

In all cases you can manually set:

IO.Params.RAW_ExtraParams := '-e';

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

xequte

38510 Posts

Posted - May 30 2015 :  22:09:49  Show Profile  Reply
@Marko,

Please advise the version number of both ielib64.dll and dcrawlib.dll

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

mhieta

Finland
78 Posts

Posted - May 31 2015 :  03:06:37  Show Profile  Reply
Hi,

Here is both:



Yep. Still using one version older dcraw plugin. I will update it later :)

- Marko
Go to Top of Page

xequte

38510 Posts

Posted - May 31 2015 :  18:44:02  Show Profile  Reply
Hi Marko

So to clarify, you call this:

IEAutoLoadIOPlugins;
ImageEnView1.IO.Params.RAW_ExtraParams := '-e';
ImageEnView1.IO.LoadFromFile( '178H0047a.dng' );


In a 32bit app you get a small JPEG preview, but in a 64bit app you get the full raw image?


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

Uwe

284 Posts

Posted - Jun 01 2015 :  08:50:20  Show Profile  Reply
Nigel, he is unable to retrieve and/or create a thumbnail using ielib64.dll and the code posted in the first post. Neither through ImageEnIO.Params.RAW_GetExifThumbnail, nor through ImageEnView1.IO.Params.RAW_ExtraParams := '-e';

If that helps: Marko's code is from VirtualThumbnails.pas of the VirtualShellTools package.

-Uwe
Go to Top of Page

mhieta

Finland
78 Posts

Posted - Jun 01 2015 :  10:53:10  Show Profile  Reply
Hi,

In 64-bit (with ielib64.dll) this does nothing:
IEAutoLoadIOPlugins;
ImageEnView1.IO.Params.RAW_ExtraParams := '-e';
ImageEnView1.IO.LoadFromFile( '178H0047a.dng' );


But in 32-bit (with dcrawlib.dll) that works okay. Like said before 32-bit is ok, but 64-bit is not working correctly (not loading image with ielib64.dll).

Yes that SpMakeThumbFromFileImageEn is from VirtualThumbnails.pas of the VirtualShellTools package.

- Marko
Go to Top of Page

xequte

38510 Posts

Posted - Jun 04 2015 :  16:02:28  Show Profile  Reply
Thanks,

We'll look into this.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

mhieta

Finland
78 Posts

Posted - Jun 05 2015 :  13:04:17  Show Profile  Reply
Thanks Nigel

- Marko
Go to Top of Page

xequte

38510 Posts

Posted - Jun 06 2015 :  05:06:01  Show Profile  Reply
Hi Marko

Actually it appears that when using ielib DNG files are not loaded as Raw by default, so it should work correctly if you explicitly use LoadFromFileRAW.

We'll reconsider this default handling for the next release.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
Jump To: