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
 ioJPEG_AUTOCALC / Scaling do they work allright?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

daansi

Netherlands
6 Posts

Posted - Feb 11 2015 :  13:11:58  Show Profile  Reply
Hi there,

I am using the code shown below to fill a NexusDB Table connected to a DevExpress QuantumGrid - CardView.
Scrolling through the Grid executes at an amazing speed (Picasa / Lightroom 5 compatible).
However scrolling slows down significantly at some records. Looking more closely at these records I noticed that they were all jpegs without an EXIF_Bitmap.
So for these records the second part of the code is executed. To check their actual size I saved the Image directly from the CardView to disc. These images were much larger then one would expect from a 160X160 pixel image.
I am quite sure that the code is correct. So I am suspecting that the scaling and loading do not work correctly as they should.


    try
      if Assigned(ImageViewer_1.IO.Params.EXIF_Bitmap) then
      begin
        //Load just the EXIF_Bitmap into ImageEnView1
        ImageViewer_1.IO.Params.GetThumbnail := True;
        ImageViewer_1.IO.LoadFromFile(aFile);
      end
      else
      //If Not EXIF-Thumb exists then read reduced size of original Picture
      begin
        ImageViewer_1.IO.Params.Width  := 160;
        ImageViewer_1.IO.Params.Height := 160;
        ImageViewer_1.IO.Params.JPEG_Scale := ioJPEG_AUTOCALC;
//        ImageViewer_1.IO.Params.JPEG_DCTMethod := ioJPEG_IFAST;
        ImageViewer_1.IO.Params.EnableAdjustOrientation := True;
        ImageViewer_1.IO.LoadFromFile(aFile);
      end;
    finally
      Field := TBlobField(tPictures.FieldByName('Thumb'));
      Stream := tPictures.CreateBlobStream(Field, bmWrite);
      ImageViewer_1.IO.SaveToStream(Stream,ioJPEG);
      ImageViewer_1.IO.CloseMediaFile;
      Stream.Free;
    end;

xequte

38615 Posts

Posted - Feb 11 2015 :  14:39:38  Show Profile  Reply
Hi

That code looks fine. Did you check JPEG_Scale_Used after loading to ensure it worked correctly?

http://www.imageen.com/help/TIOParamsVals.JPEG_Scale_Used.html

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

daansi

Netherlands
6 Posts

Posted - Feb 12 2015 :  03:57:13  Show Profile  Reply
Hi Nigel,

Thanks for your quick reply. I checked that already, thanks.
But my point remains: when setting width and height to 160X160, you expect that the image read into the datbasefield will not exceed these measures.
When I add a button excuting ImageEnView1.Proc.DoPreviews(ppeEffects) in your IPTC demo and look at the Resize tab I see sizes like (648X432) which is indeed One_Eighth of the original but that is not what you expect when you set the dimensions 160X160.
With thousands of photos the database will grow unnecessarily.
Helas many photos still not contain EXIF_Thumbs - which are read smoothly in very small sizes into the table.
So is there a way to set the scale of the image exactly to the desired dimensions before actually loading the image?

Thanks in advance Daan
Go to Top of Page

xequte

38615 Posts

Posted - Feb 12 2015 :  18:17:54  Show Profile  Reply
Hi Daan

That is not the way ioJPEG_AUTOCALC works, in fact if you set width and height to 160x160, then the image is guaranteed to be larger than this.

If you want the image to be 160x160 you should resample it after loading. You might want to look at IELoadAsThumbnail:

http://www.imageen.com/help/TBitmap.IELoadAsThumbnail.html

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

daansi

Netherlands
6 Posts

Posted - Feb 13 2015 :  08:00:32  Show Profile  Reply
Hi Nigel,

Really awesome, just beat Picasa scrolling through thousands of photos.
Resampling was not necessary after loading, I used IELoadAsThumbnail directly to load the image from disc into the Database.

Cheers, Daan
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: