ImageEn FAQ

How can I prevent the scrollwheel from causing the image to zoom? I want it to remain the orginal size at all times.
 
How do I convert a GIF image to TIFF format without a visual component?
 
Can I modify brightness?
 
Can I modify scanner resolution?
 
Is there any way to save a CMYK TIFF using ImageEn?
 
When I try to resample a picture I get the compiler error : TResampleFilter is not defined!
 
Is it possible to de/activate duplex on scanner?
 
I'm trying to insert some text in the raw frame using the event OnVideoFrameRaw.  How can I get a canvas from the parameters of this event?
 
Can your component take a series of single page TIFF files and create a Multi-Page file from them?
 
How to change the current page of a TIFF image in TImageEnView?
 
Is it possible to convert a multipage-image to a different encoding? G3 and G4 specifically?
 
How do I get the transparent PNGs to work inside your vector view control?
 
I would like users to be able to resize and move vectorial objects when they are displayed on the screen. Is it possible? How can I do that?
 
How can I display images "on demand" with TImageEnMView?
 
How do I save (burn) lines, ellipses, etc. into the JPEG?
 
How do I modify the IPTC fields without loading the original image?
 
How do I print all the images in a multipage TIFF?
 
How I can save my jpeg without EXIF or other metadata?
 
How can I check if the TImageEnView is empty (no bitmap loaded)?
 
When a user selects a page of the multipage TIFF image (using TImageEnMView) how do I display this image in a TImageEnView?
 
How do I assign the image in one ImageEnView to another ImageEnView?
 
Which is the correct way to load a Resource Image at runtime into an TImageEnView component, in C++?
 
How read custom TIFF tags?
 
How do I compress my JPEGs to make them smaller?
 
How do I save an image with its objects when using TImageEnVect?
 
How do I store/retrieve multiple pages in a blob field using TImagenDBView?
 
How do I load embedded JPEG images in a Raw file
 
How do I terminate a polyline without double-clicking?
 
How do I read recent camera RAW files?
 
Measuring line length using miLineLen (or miArea) does not work. The mouse pointer only shows 0.00 pixels and nothing happens.
 
I get "Floating point overflow" on printing.
 
I see horizontal/vertical bands loading images using TImageEnMView. Why?
 

Top of Page

How can I prevent the scrollwheel from causing the image to zoom? I want it to remain the orginal size at all times.
Just write:

ImageEnView1.MouseWheelParams.Action:=iemwNone;

other values are iemwVScroll and iemwZoom (default).

Top of Page

How do I convert a GIF image to TIFF format without a visual component?
There are several ways. The simplest is:

var
  ie:TImageEnView;
begin
  ie:=TImageEnView.Create(nil);
  ie.IO.LoadFromFile('in.gif');
  ie.IO.SaveToFile('out.gif');
  ie.free;
end;

 

You can also create a TIEBitmap (or TBitmap) object that contains the image. This is the code:

var
  bmp:TIEBitmap;
  io:TImageEnIO;
Begin
  bmp:=TIEBitmap.Create;
  io:=TImageEnIO.CreateFromBitmap(bmp);
  io.LoadFromFile('in.gif');
  io.SaveToFile('out.gif');
  io.free;
  bmp.free;
End;


Top of Page

Can I modify brightness?
You can change brightness (luminosity) using several methods.

Using IntensityRGBall method:

  ImageEnView1.Proc.IntensityRGBall(20,20,20); // increment luminosity of 20 (the fastest)

Using HSLvar method:

  ImageEnView1.Proc.HSLvar(0,0,20); // increment luminosity of 20 (slow but more accurate)

Using HSVvar method:

  ImageEnView1.Proc.HSVvar(0,0,20); // increment luminosity of 20 (slow but more accurate)

Top of Page

Can I modify scanner resolution?
To change scan resolution to 300 on your scanner use:

ImageEnView1.IO.TWainParams.XResolution.CurrentValue:=300;
ImageEnView1.IO.TWainParams.YResolution.CurrentValue:=300;
ImageEnView1.IO.Acquire;

Top of Page

Is there any way to save a CMYK TIFF using ImageEn?
To save TIFF with CMYK write:

ImageEnView1.IO.Params.TIFF_PhotometInterpret:=ioTIFF_CMYK;

ImageEnView1.IO.SaveToFile('xxx.tif');

Top of Page

When I try to resample a picture I get the compiler error : TResampleFilter is not defined!
You have to add to the "uses" list the "hyiedefs" unit:

uses hyiedefs;

Top of Page

Is it possible to de/activate duplex on scanner?
Write ImageEnView1.IO.TWainParams.DuplexEnabled:=True (or False if you want disable).

Top of Page

I'm trying to insert some text in the raw frame using the event OnVideoFrameRaw.  How can I get a canvas from the parameters of this event?
Instead of use OnVideoFrameRaw you have to use OnVideoFrame that returns a Bitmap object.

From Bitmap object you can obtain the Canvas with:

Bitmap.Canvas

Top of Page

Can your component take a series of single page TIFF files and create a Multi-Page file from them?
You can load the page using:

  ImageEnView1.IO.LoadFromFile('page1.tif');

then save the page with:

  ImageEnView1.IO.Params.TIFF_ImageIndex:=0; // increment this for each page

  ImageEnView1.IO.InsertToFileTIFF('multipage.tif');

Otherwise you can use TImageEnMView and TImageEnMIO component. See "multi" example for more details.

Top of Page

How do I change the current page of a TIFF image in TImageEnView?
In order to load several pages from a TIFF you have two ways:

1) load a page at the time, using TImageEnView, example:

ImageEnView1.IO.Params.TIFF_ImageIndex:= page_number; // page_number stars from 0 (first page)

ImageEnView1.IO.LoadFromFile('mytiff.tiff');

First instruction select the page to load. To know how many pages there are use:

page_count:=EnumTIFFIm('mytiff.tiff');

2) load all pages, using TImageEnMView. Just write:

ImageEnMView1.MIO.LoadFromFile('mytiff.tiff');

and you will see all pages.

Top of Page

Is it possible to convert a multipage-image to a different encoding? G3 and G4 specifically?
Using TImageEnMView you have to change the compression property for all pages:

ImageEnMView1.MIO.LoadFromFile('original.tif');
// change compression for the first page
ImageEnMView1.MIO.Params[0].TIFF_Compression := ioTIFF_G4FAX;
// change compression for the other pages
ImageEnMView1.MIO.DuplicateCompressionInfo;
// now save
ImageEnMView1.Mio.SaveToFile('output.tif');

Top of Page

How do I get the transparent PNGs to work inside your vector view control?
To load the alpha channel from PNG (and others) you have to use SetObjBitmapFromFile method:

ImageEnVect1.SetObjBitmapFromFile(hobj, 'test.png');

Top of Page

I would like users to be able to resize and move vectorial objects when they are displayed on the screen. Is it possible? How can I do that?
To enable users to modify (move,resize) objects just set:

ImageEnVect1.MouseInteractVt:=[miObjectSelect];

The users can select then modify objects.

Top of Page

How can I display images "on demand" with TImageEnMView?
There are several ways to display images "on demand":

1) If you have a directory where are all files just write:
ImageEnMView1.FillFromDirectory('c:\myimages');

2) When you add a new image just set ImageFileName[] index, and ImageEn will load automatically specified file when needed. Example:

idx:=ImageEnMView1.AppendImage;
ImageEnMView1.ImageFileName[idx]:='first.jpg';

3) When you add a new image just set the ImageID[] property. You have to create by hand an array of filenames where to get images. Example:

var
  files:array [0..1] of string;
begin
  files[0]:='first.jpg';
  files[1]:='second.jpg';
  ImageEnMView1.ImageID[ ImageEnMView1.AppendImage ] := 0;
  ImageEnMView1.ImageID[ ImageEnMView1.AppendImage ] := 1;
end;

You have also to create OnImageIDRequest event, on this you can write:

procedure TForm1.OnImageIDRequest(Sender: TObject; ID:integer; var Bitmap:TBitmap);
var
  io:TImageEnIO;
begin
  io:=TImageEnIO.Create(self);
  io.AttachedBitmap:=bmp; // bmp is a TBitmap object, defined at class level (must exists after the OnImageIDRequest exits)
  io.LoadFromFile( files[ID] );
  io.free;
  Bitmap:=bmp;
end;

4) If the images are frames of a media file (like AVI, MPEG, etc..) you can write:

ImageEnMView1.LoadFromFileOnDemand('film.mpeg');

Top of Page

How do I save (burn) lines, ellipses, etc. into the JPEG?
Use CopyObjectsToBack method, then save the background image.

Top of Page

How do I modify the IPTC fields without loading the original image?
To load IPTC info from a jpeg, just use LoadFromFile method. After this you have in ImageEnView.IO.Params.IPTC_Info object all IPTC informations loaded. To read the caption you can write:

ImageEnView.IO.LoadFromFile('image.jpg');
Idx:=ImageEnView.IO. Params.IPTC_Info.IndexOf(2,120);
Caption:= ImageEnView.IO.Params.IPTC_Info.StringItem[idx];

this modify the caption:

ImageEnView.IO.Params.IPTC_Info.StringItem[idx] := 'new caption';
ImageEnView.IO.SaveToFile('image2.jpg');

If you want to modify IPTC info without load the image use ParamsFromFile and InjectJpegIPTC methods, in this way:

ImageEnView.IO.ParamsFromFile('one.jpg');

...here modify the IPTC info

ImageEnView.IO.InjectJpegIPTC('two.jpg');

Top of Page

How do I print all the images in a multipage TIFF?
You can connect a TImageEnIO to a TImageEnMView. TImageEnIO.PrintImage will print the selected image (use SelectedImage to change current selected image). In this way you can print all pages:

for i:=0 to ImageEnMView1.ImageCount-1 do
begin
  ImageEnMView1.SeletedImage := i;
  ImageEnIO.PrintImage...
end;

You can also use the predefined dialog of TImageEnMView componet. Just write:

ImageEnMView.MIO.DoPrintPreviewDialog;

Top of Page

How I can save my jpeg without EXIF or other metadata?
Call Params.ResetInfo. Example:

ImageEnView.IO.LoadFromFile('input.jpg');
ImageEnView.IO.Params.ResetInfo;
ImageEnView.IO.SaveToFile('output.jpg');

Top of Page

How can I check if the TImageEnView is empty (no bitmap loaded)?
To empty the component use "Blank" method. To check if it is empty use IsEmpty:

If ImageEnView1.IsEmpty then
...

Top of Page

When a user selects a page of the multipage TIFF image (using TImageEnMView) how do I display this image in a TImageEnView?
To handle image selection use OnImageSelect event. To transfer current selected image use simply the Assign method:

procedure TForm1.ImageEnMView1ImageSelect(Sender: TObject; idx: Integer);
begin
  ImageEnView1.Assign( ImageEnMView1.Bitmap );
end;

Top of Page

How do I assign the image in one ImageEnView to another ImageEnView?
Just use Assign method:

ImageEnView1.Assign( ImageEnView2 );

or

ImageEnView1.Assign( ImageEnView1.Bitmap ); // this doesn't copy DPI, but just the image

Top of Page

Which is the correct way to load a Resource Image at runtime into an TImageEnView component, in C++?
Here is a sample code:

    TResourceStream *ResourceImage;
    // Load from resource the About image ( a JPEG file).
    ResourceImage = new TResourceStream((int)HInstance, "ABOUTBITMAP",RT_RCDATA);
    MainForm->ImageAbout->IO->LoadFromStreamJpeg(ResourceImage);
    delete ResourceImage;


Here is a single line text file named "resource.rc" with the sentence:

ABOUTBITMAP RCDATA "about.jpg"

Just add the Resource file to the project and compile.

Top of Page

How read custom TIFF tags?
This example shows how read EXIF tags saved with Canon cameras:

var
  ms:TMemoryStream;
  tagReader1,tagReader2,tagReader3:TIETifTagsReader;
  i:integer;
  // some Canon tags
  m_nMacroMode,m_nLenghtTimer,m_Quality:integer;
  m_ImageType:string;
begin
  with imageenvect1 do begin

    IO.LoadFromFile('Capture_00006.JPG');
    with IO.Params.JPEG_MarkerList do begin
      i:=IndexOf( JPEG_APP1 );
      if i>=0 then begin
        // there are EXIF info
        ms:=TMemoryStream.Create;
        ms.Write( MarkerData[i][6], MarkerLength[i] ); // bypass first 4 bytes (must contain 'Exif')
        ms.Position:=0;

        tagReader1:= TIETifTagsReader.CreateFromStream( ms,0 ); // read TIFF's IFD

        tagReader2:= TIETifTagsReader.CreateFromIFD( tagReader1, 34665 ); // read IFD in tag 34665 (SubEXIF)

        tagReader3:= TIETifTagsReader.CreateFromIFD( tagReader2, $927c ); // read IFD in tag $927C (MarkerData - Canon IFD data)

        // read Canon EXIF tags
        m_nMacroMode:=tagReader3.GetIntegerIndexed(1,1);
        m_nLenghtTimer:=tagReader3.GetIntegerIndexed(1,2);
        m_Quality:=tagReader3.GetIntegerIndexed(1,3);
        m_ImageType:=tagReader3.GetString(6);

        tagReader3.Free;
        tagReader2.Free;
        tagReader1.Free;

        ms.Free;
      end;
    end;
  end;
end;

Top of Page

How do I compress my JPEGs to make them smaller?
Jpeg is a file format with variable compression rate. The property that regulates the compression (and the quality) is JPEG_Quality. So you should set this property before save. Example:

ImageEnView.IO.LoadFromFile('input.jpg');
ImageEnView.IO.Params.JPEG_Quality:=70;
ImageEnView.IO.SaveToFile('output.jpg');

The default is 80, while other software uses 70.
If you want estimate the value used to create your file, execute this:
quality:=IECalcJpegFileQuality('input.jpg');

So you could write:

ImageEnView.IO.LoadFromFile('input.jpg');
ImageEnView.IO.Params.JPEG_Quality:=IECalcJpegFileQuality('input.jpg');
ImageEnView.IO.SaveToFile('output.jpg');

If this is not enough, probably the file contains metatags (text info). To remove them execute:

ImageEnView.IO.Params.ResetInfo;

..just before save.

Top of Page

How do I save an image with its objects when using TImageEnVect?
here is all options of ImageEn:

1)
if you want to save only objects:

ImageEnVect1.SaveToFileIEV('file.iev');

to load back:

ImageEnVect1.LoadfromFileIEV('file.iev');


2)
If you want save objects and image:

ImageEnVect1.SaveToFileAll('file.all');

and to load:

ImageEnVect1.LoadFromFileAll('file.all');

3)
If you want save objects and image as standard tiff and using Imaging Annotations (readable by Windows Preview):

ImageEnVect1.IO.SaveToFile('file.tif');
ImageEnVect1.SaveObjectsToTIFF('file.tif');

to load:

ImageEnVect1.IO.LoadFromFile('file.tif');
ImageEnVect1.LoadObjectsFromTIFF('file.tif');

4)
If you want save objects inside a jpeg or other formats which do not support Imaing Annotations, or you just want to merge image and objects:

ImageEnVect1.CopyObjectsToBack;
ImageEnVect1.IO.SaveToFile('file.jpg');

Top of Page

How do I store/retrieve multiple pages in a blob field using TImagenDBView?
TImageEnDBView cannot store/retrieve multiple pages in a blob. However there is a solution.
You can put a TImageEnMView component on the form and use it to load/save multiple pages as TIFFs in blobs using streams.
To store the content of TImageEnMView inside a blob write:

var tempStream:TMemoryStream;

tempStream:=TMemoryStream.Create;
ImageEnMView1.MIO.SaveToStreamTIFF( tempStream );
BlobField.LoadFromStream( tempStream );
tempStream.free;

To retrieve from a blob:

tempStream:=TMemoryStream.Create;
BlobField.SaveToStream( tempStream );
tempStream.Position:=0;
ImageEnMView1.MIO.LoadFromStreamTIFF( tempStream );
tempStream.free;

If you use a TDataSet inherited data set you can create a blob stream without using intermediate TMemoryStream: this will speedup operations. Example:

BlobStream:= myDataSet.CreateBlobStream(field, bmWrite);
ImageEnMView1.MIO.SaveToStreamTIFF( BlobStream );
BlobStream.Free;

..and..

BlobStream:= myDataSet.CreateBlobStream(field,bmRead);
ImageEnMView1.MiO.LoadFromStreamTIFF( BlobStream );
BlobStream.Free;


Finally, when save you can set compression info. For example, for black/white images you could write:

ImageEnMView1.MIO.Params[0].TIFF_Compression:= ioTIFF_G4FAX;
ImageEnMView1.MIO. DuplicateCompressionInfo;
..just before save.

Top of Page

How do I load embedded JPEG images in a Raw file?
Unfortunately Camera RAW formats aren't documented. Anyway it is possible to load embedded jpegs from NEF, CR2 and DNG raw formats. Examples:

DNG:
ImageEnView1.IO.Params.TIFF_SubIndex:=1;
ImageEnView1.IO.LoadFromFileTIFF('input.dng');

CR2:
ImageEnView1.IO.Params.ImageIndex:=0;
ImageEnView1.IO.LoadFromFileTIFF('input.cr2');

NEF:
ImageEnView1.IO.Params.ImageIndex:=1;
ImageEnView1.IO.LoadFromFileTIFF('input.nef');

CRW:
ImageEnView1.IO.LoadJpegFromFileCRW('input.crw');

Top of Page

How do I terminate a polyline without double-clicking?
Just set:

ImageEnVect.PolylineEndingMode:=ieemMouseUp;

Top of Page

How do I read recent Camera RAW files?
In order to read recent Camera RAW files you need to use the Dcraw plug-in.

Top of Page

Measuring line length using miLineLen (or miArea) does not work. The mouse pointer only shows 0.00 pixels and nothing happens.
miLineLen measures the perimeter of current selection. So a selection must be present. The same is for miArea which measures the area of current selection.
To measure the length of a line write instead:
ImageEnVect.MouseInteractVt:=[miDragLen];

Top of Page

I get "Floating point overflow" on printing.
Sometime this happens on shared printers and depends by VCL or printer drivers bug.
Try to disable FPU exceptions executing this before your printing code:

Set8087CW($133F);

Top of Page

I see horizontal/vertical bands loading images using TImageEnMView. Why?
By default, TImageEnMView loads EXIF thumbnails when they are available (with the thumbnail display method).
Sometimes these thumbnails contain black bands (horizontal or vertical bands).
To disable EXIF thumbnails loading set:
TImageEnMView.EnableLoadEXIFThumbnails := false;