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
 Thumbnails And Resolution Issues

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
andyhill Posted - Sep 27 2015 : 16:31:14
I have experimented on W10 with DX trying to get fast thumbnail save routine and only Mode 1 works correctly. All other modes produce a heavily pixelated output, please advise what I am doing wrong - thanks in advance.

  for i:= 0 to mvHorz.ImageCount - 1 do begin
    if mvHorz.MIO.Params[i].FileName = '' then Continue;
    iThumbnailFilename:= iFolder + JustName(mvHorz.MIO.Params[i].FileName) + '_thumbnail.jpg';
    //
    if Mode = 1 then begin // Load From File Into ImageEn, ReSample And Save
      Image.IO.LoadFromFile(mvHorz.MIO.Params[i].FileName);
      Image.Proc.Resample(100, 100, rfFastLinear, True);
      Image.IO.SaveToFileJpeg(iThumbnailFilename);
    end;

    if Mode = 2 then begin // Load From File Into IEBitmap, Convert To Thumb And Save
      iIEBitmap:= TIEBitmap.Create;
      Bitmap:= TBitmap.Create;
      Graphic:= nil;
      FS:= TFileStream.Create(mvHorz.MIO.Params[i].FileName, fmOpenRead);
      try
        SetLength(FirstBytes, 8);
        FS.Read(FirstBytes[1], 8);
        if Copy(FirstBytes, 1, 2) = 'BM' then begin
          Graphic := TBitmap.Create;
        end else if FirstBytes = #137'PNG'#13#10#26#10 then begin
          Graphic:= TPngImage.Create;
        end else if Copy(FirstBytes, 1, 3) =  'GIF' then begin
          Graphic:= TGIFImage.Create;
        end else if Copy(FirstBytes, 1, 2) = #$FF#$D8 then begin
          Graphic:= TJPEGImage.Create;
        end;
        if Assigned(Graphic) then begin
          try
            FS.Seek(0, soFromBeginning);
            Graphic.LoadFromStream(FS);
            Bitmap.Assign(Graphic);
            iIEBitmap.CopyFromTBitmap(Bitmap);
            iIEBitmap.IEConvertToThumbnail(100, 100, Stretch, rfLanczos3, Border, BorderColor, Shadow, BlurRadius, ShadowOffset, ShadowColor, BackgroundColor); // hyiedefs
            iIEBitmap.IESaveToFile(iThumbnailFilename, ioJPEG);
          except
          end;
          Graphic.Free;
        end;
      finally
        FS.Free;
        Bitmap.Free;
        iIEBitmap.Free;
      end;
    end;

    if Mode = 3 then begin // Load Into IEBitmap From ImageEnMView, Convert To Thumb And Save
      iIEBitmap:= TIEBitmap.Create;
      try
        iIEBitmap:= mvHorz.GetTIEBitmap(i);
        {rfNone, rfTriangle, rfHermite, rfBell, rfBSpline, rfLanczos3, rfMitchell, rfNearest, rfLinear, rfFastLinear, rfBilinear, rfBicubic, rfProjectBW, rfProjectWB, rfWICNearestNeighbor, rfWICLinear, rfWICCubic, rfWICFant}
        iIEBitmap.IEConvertToThumbnail(100, 100, Stretch, rfLanczos3, Border, BorderColor, Shadow, BlurRadius, ShadowOffset, ShadowColor, BackgroundColor); // hyiedefs
        iIEBitmap.IESaveToFile(iThumbnailFilename, ioJPEG);
      except
      end;
      iIEBitmap.Free;
    end;

    if Mode = 4 then begin // Load From File As Thumbnail Into IEBitmap And Save
      iIEBitmap:= TIEBitmap.Create;
      try
        iIEBitmap.IELoadAsThumbnail(mvHorz.MIO.Params[i].FileName, 100, 100, False);
        iIEBitmap.IESaveToFile(iThumbnailFilename, ioJPEG);
      except
      end;
      iIEBitmap.Free;
    end;

    if Mode = 5 then begin // Load From File Into IEBitmap, Resample And Save
      iIEBitmap:= TIEBitmap.Create;
      try
        iIEBitmap.IELoadFromFile(mvHorz.MIO.Params[i].FileName, 100, 100, False);
        iIEBitmap.Resample(100, 100, rfLanczos3, True);
        iIEBitmap.IESaveToFile(iThumbnailFilename, ioJPEG);
      except
      end;
      iIEBitmap.Free;
    end;

    Break;
  end;


Andy
7   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Sep 28 2015 : 23:38:10
Hi Andy

There is no "best" as such as it rather subjective and everyone has their favorites. I personally like rfLanczos3 for best quality, or rfFastLinear for a good compromise between speed and quality.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
andyhill Posted - Sep 28 2015 : 15:44:52
This brings me to my next question.

What is the best Filter to use for Resampling when:-

Down Scaling ?

Up Scaling ?

in order to produce maximum definition.


Andy
andyhill Posted - Sep 28 2015 : 14:53:44
Thank You Nigel and Bill for your comments.

It was kind of you Bill to produce a demo.

As I learnt by experimentation and as confirmed by your code, the best resolution is produced by ImageEn ReSampling.


Andy
w2m Posted - Sep 28 2015 : 12:29:07
For mode 3 do not create the IEBitmap... this causes problems... Just get the image from ImageEnMView and then free it by calling ReleaseBitmap.
if iMode = 3 then
    begin // Load Into IEBitmap From ImageEnMView, Convert To Thumb And Save
      iIEBitmap := ImageEnMView1.GetTIEBitmap(i);
      try
        iIEBitmap.IEConvertToThumbnail(100, 100, Stretch1.Checked,
          TResampleFilter(ResampleFilter1.ItemIndex), Border1.Checked,
          BorderColor1.Selected, Shadow1.Checked, BlurRadius1.Position,
          ShadowOffset1.Position, ShadowColor1.Selected,
          BackgroundColor1.Selected);
        ImageEnView1.IEBitmap.Assign(iIEBitmap);
        ImageEnView1.Update;
        // iIEBitmap.IESaveToFile(iThumbnailFilename, ioJPEG);
      finally
        ImageEnMView1.ReleaseBitmap(i);
      end;
    end;

I have created a small demo that uses your code but modified it a bit. The different modes do produce different results depending on the parameters set with some modes. I just pick the one that gives you the best results. The demo allows you to compare the result from each mode by tiling each of the thumbnails so you can visually compare them easily. If you have a touch monitor you can zoom in and out with a touch gesture.

The demo may be downloaded here:
http://www.imageen.com/ieforum/topic.asp?whichpage=4&TOPIC_ID=1446#8353

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
w2m Posted - Sep 28 2015 : 08:17:26
What are the dimensions of the source images?

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
xequte Posted - Sep 27 2015 : 20:46:48
Hi Andy

I can't see anything particularly wrong with your code. Please post some before and after examples.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Sep 27 2015 : 16:36:49
Without diving deep into your code, I notice you are using a resample filter. With small thumbnails this causes pixilation, so do not use a filter. Set filter to rfNone. Do not use rfFastLinear or rfLanczos3... in fact always use rfNone.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development