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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 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

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
mhieta Posted - May 27 2015 : 08:47:42
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
20   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jun 10 2015 : 21:43:07
Hi Marko

Yes, neither of these files support "-e" in 32bit or 64bit. Presumably they do not include an embedded preview image.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
mhieta Posted - Jun 10 2015 : 14:23:55
Hi,

Sorry still not success with every raw image what I have:

Here is couple raw images what has some issues:
http://koti.mbnet.fi/mhieta/temp/100.RAW
http://koti.mbnet.fi/mhieta/temp/2003_03b_IMG_1432.DNG

- Marko
xequte Posted - Jun 09 2015 : 21:02:22
Hi Marko

Thanks for the demo. I realize now that there is a quirk in IEAutoLoadIOPlugins that it does not remove the internal raw handling when using ielib. I will fix this for the next update.

In the meantime you can use:

  if OpenImageEnDialog1.Execute then
  begin    
    {$ifdef WIN64}
    IEFileFormatRemove(ioRAW);
    {$ENDIF}
    IEAutoLoadIOPlugins;
    ImageEnView1.IO.Params.RAW_ExtraParams := '-e';
    ImageEnView1.IO.LoadFromFileRAW( OpenImageEnDialog1.FileName );
  end;



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
mhieta Posted - Jun 07 2015 : 06:23:08
Hi Nigel,

Here is complete simple example:
http://koti.mbnet.fi/mhieta/temp/Project1.zip

Inside zip there is also compiled 32-bit and 64-bit exe files and dcrawlib.dll and ielib64.dll included. And there is couple of sample files included too.

And the code is:
if OpenImageEnDialog1.Execute then
  begin
    IEAutoLoadIOPlugins;
    ImageEnView1.IO.Params.RAW_ExtraParams := '-e';
    ImageEnView1.IO.LoadFromFileRAW( OpenImageEnDialog1.FileName );
  end;


And yes it still fails to load several raw images including those sample files.

That 178H0047a.dng is loaded okay in 32-bit and 64-bit.

- Marko
xequte Posted - Jun 07 2015 : 03:32:14
Hi Marko

LoadFromFileRAW and LoadFromStreamRAW will give the same result.

Does this still fail?


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


Please give specific examples of other failures.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
mhieta Posted - Jun 06 2015 : 10:23:10
Hi Nigel,

I was already using:
ImageEnIO.LoadFromStreamRAW(F);

how that LoadFromFileRAW differs from LoadFromStreamRAW ? Any differ than file load and other is from stream loading ?

Still with this LoadFromFileRAW many raw files is not loaded. I have so many different raw files so I cannot post them all, sorry. Anyway those are loaded fine with dcrawlib.dll in 32-bit.

- Marko
xequte Posted - Jun 06 2015 : 05:06:01
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
mhieta Posted - Jun 05 2015 : 13:04:17
Thanks Nigel

- Marko
xequte Posted - Jun 04 2015 : 16:02:28
Thanks,

We'll look into this.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
mhieta Posted - Jun 01 2015 : 10:53:10
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
Uwe Posted - Jun 01 2015 : 08:50:20
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
xequte Posted - May 31 2015 : 18:44:02
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
mhieta Posted - May 31 2015 : 03:06:37
Hi,

Here is both:



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

- Marko
xequte Posted - May 30 2015 : 22:09:49
@Marko,

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

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
xequte Posted - May 30 2015 : 22:07:39
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
mhieta Posted - May 29 2015 : 10:38:19
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
Uwe Posted - May 29 2015 : 09:51:06
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
xequte Posted - May 29 2015 : 04:20:49
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
mhieta Posted - May 28 2015 : 14:09:25
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
Uwe Posted - May 28 2015 : 12:52:48
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.