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
 Save NEF (nikon RAW) as TIFF

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
DMC02766 Posted - Dec 07 2015 : 15:22:38
Hi-
I currently have a button on my form in order to save the current loaded image into another directory as a TIFF. The purpose of this is to save "snapshots" of the image so the user can restore later if need be. The problem I am having is Tiff images are working fine when saving but when I have an NEF file loaded, it does not save the image.

My code:

IMGVIEW2 is a TImageEnVect


procedure Tfrm_main.SNAPSHOT2SAVE;
var
PATH1: STRING;
FILE1: STRING;
IMGFILE: STRING;
IMGDIR: string;
ext1: string;
fName: string;
i: integer;

begin
PATH1:= SNAPSHOTDIRECTORY.Text;
FILE1:= (extractfilename(i2.Text));
ext1:=  (extractfileext(i2.Text));
IMGFILE:=  (PATH1+ '\'+ file1+ '\'+ timeTOSTR(time)+ ' SNAPSHOT '+ FILE1);
IMGDIR:=  (PATH1+ '\'+ file1);

imgview2.Cursor := crDefault;

  imgview2.Layers[0].Locked := false;
forcedirectories(imgdir);
imgview2.IO.Params.ImagingAnnot.CopyFromTImageEnVect(Imgview2);
//save image
  imgview2.IO.SaveToFile(IMGFILE, iotiff);
    //save layers from the image
    if imgview2.LayersCount > 1 then
    begin
    imgview2.LayersSaveToFile(IMGFILE + '.lyr', -2);
    end;
end;



Also, I am not 100% sure of the difference in these two forms of saving as well which could be part of my problem:
imgview2.IO.SaveToFile(IMGFILE, iotiff);
imgview2.io.savetofiletiff(imgfile);

Ive tried both ways and cannot get it to save the loaded images as tiff.

Any help would be greatly appreciated.
5   L A T E S T    R E P L I E S    (Newest First)
DMC02766 Posted - Dec 08 2015 : 17:13:06
I will get that fixed... Thanks again for your help and advice, I really do appreciate it.
xequte Posted - Dec 08 2015 : 16:42:12
Sorry, when I tested I didn't check your string manipulation, only the ImageEn code.

Firstly, you should not need to use ForceDirectories(). ImageEn does not care about the current directory if you are passing a full path.

Yes, filenames cannot use colons, except after a drive letter. Also, you should use IncludeTrailingBackslash() rather than hard code slash characters (because you cannot be sure whether a passed path includes or does not include a slash).

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
DMC02766 Posted - Dec 08 2015 : 10:32:06
So I did some more adjusting of the code to try to figure out what was causing it and think I have figured it out. This line:

IMGFILE:= (PATH1+ '\'+ file1+ '\'+ timeTOSTR(time)+ ' SNAPSHOT '+ FILE1);

I started by changing the force directory to be just the file name (minus the extension) and then it started erroring out when saving any file (not really sure why because it was creating the directory properly). So I then changed the above line to

IMGFILE:= (PATH1+ '\'+ file1+ '\'+ ' SNAPSHOT '+ FILE1);

Now it saves properly. Im assuming the time colons were causing it to not save properly in the filename?

My new code (still messy, so please excuse the mess) goes like this:


procedure Tfrm_main.SNAPSHOT2SAVE;
var
PATH1: STRING;
FILE1: STRING;
IMGFILE: STRING;
IMGDIR: string;
ext1: string;
FILENOEXT: string;


begin

PATH1:= SNAPSHOTDIRECTORY.Text;
FILE1:= (extractfilename(i2.Text));
FILENOEXT:=  (changefileext(file1,''));
 ext1:=  (extractfileext(i2.Text));
IMGDIR:=  (PATH1+ '\'+ filenoext);
IMGFILE:=  (IMGDIR+ '\'+ 'SNAPSHOT '+ filenoext);
imgview2.Cursor := crDefault;
  imgview2.Layers[0].Locked := false;
forcedirectories(imgdir);
sleep(100);
imgview2.IO.Params.ImagingAnnot.CopyFromTImageEnVect(Imgview2);
  imgview2.IO.SaveToFileTIFF(IMGFILE +'.TIF');
 
snapcount.Text := inttostr(imgsnap.ImageCount);
end;

DMC02766 Posted - Dec 08 2015 : 08:27:37
Thanks for your reply Nigel! You are right, I definitely need to do some cleanup on the code. I was trying a few other things with it originally (raw conversion thinking I could store the image in a stream / temp then resave to fix the issue) and left it with messy code. I will email over the image file in just a sec. Thanks again for your help, I really appreciate it.
xequte Posted - Dec 08 2015 : 03:53:43
Hi

I cannot see anything wrong with the code (though a little code formatting wouldn't hurt ). And when I try it on my system with a NEF file it works fine. Can you email me your NEF file? Perhaps there is something particular about the file.

There is no difference between:
imgview2.IO.SaveToFile(IMGFILE, iotiff);
imgview2.io.savetofiletiff(imgfile);


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com