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
 How to resize a TIEBitmap

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
quantuz Posted - Oct 19 2012 : 10:52:59
Hi,
How can I resize TIEBitmap that doesnt have an associated ImageEnView?
I already have the data in a TIEBitmap and don want to make a copy to a new ImageEnView, i.e. I want to avoid making a copy.
Is there not a Encapsulate() metod that take a TIEBitmap?
If ResampleTo() is the routine to use,how can I create a (temporary) ImageEnView so I can use ResampleTo() ?
I must also be able to delete the temporary ImageEnView after resize.
Or is there some other way to accomplish resizing a TIEBitmap directly?

Best Regards,
//Crister Strandh
1   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Oct 19 2012 : 12:34:44
Here is one way to do it:
procedure TForm1.ResampleIEBitmap1Click(Sender: TObject);
// Resample a TIEBitmap
var
  iIEBitmap: TIEBitmap;
  iImageEnProc: TImageEnProc;
  iImageEnIO: TImageEnIO;
  iFilename: string;
  iExtension: string;
  iFileType: TIOFileType;
begin
  // Build the save picture dialog filter
  SavePictureDialog1.Filter := '';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'JPEG Bitmap (*.jpg; *.jpeg)|*.jpg;*.jpeg|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'TIF Bitmap (*.tif; *.tiff)|*.tif;*.tiff|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'Compuserve Bitmap (*.gif)|*.gif|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'PaintBrush (*.pcx)|*.pcx|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'Windows Bitmap (*.bmp; *.dib)|*.bmp;*.dib|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'Windows Icon (*.ico)|*.ico|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'Portable Network Graphics (*.png)|*png|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'Targa Bitmap (*.tga)|*.tga|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'Portable Pixmap (*.pxm)|*.pxm|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'Wireless Bitmap (*.wbmp)|*.wbmp|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'JPeg 2000 (*.jp2)|*.jp2|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'JPeg2k (*.j2k)|*.j2k|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'PostScript Level 2 (*.ps;*.eps)|*.ps;*.eps|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'Adobe PDF (*.pdf)|*.pdf|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'Multipage PCX (*.dcx)|*.dcx|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'Photoshop PSD (*.psd)|*.psd|';
  SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'Microsoft HD Photo (*.hdp;*.wdp) |*.hdp;*.wdp|';
  SavePictureDialog1.FileName := JustName(ImageEnView1.IO.Params.FileName) + '.png';
  SavePictureDialog1.FilterIndex := 7;
  SavePictureDialog1.DefaultExt := '.png';
  SavePictureDialog1.FileName := ExtractFilename(ImageEnView1.IO.Params.FileName);
  SavePictureDialog1.Title := 'Save As- ' + ImageEnView1.IO.Params.FileName;
  SavePictureDialog1.Options := [ofOverwritePrompt, ofHideReadOnly, ofEnableSizing];
  if SavePictureDialog1.Execute then
    if SavePictureDialog1.FileName <> '' then
    begin
      Screen.Cursor := crHourGlass;
      try
        iFilename := SavePictureDialog1.FileName;
        iExtension := ExtractFileExt(iFilename);
        iFileType := IEExtToFileFormat(iExtension);
        Caption := 'ImageEn Procedures From A To Z- ' + iFilename;
        // Create a TIEBitmap to hold the image
        iIEBitmap := TIEBitmap.Create;
        try
          // Assign the TIEBitmap in TImageENView1 to iIEBitmap
          iIEBitmap.Assign(ImageEnView1.IEBitmap);
          // In your case you already have an TIEBitmap so just assign your TIEBitmap to iIEBitmap as shown below and remark the previous line
          // iIEBitmap.Assign(YourIEBitmap);
          // Create a TimageEnProc to Resample the TIEBitmap
          iImageEnProc := TImageEnProc.Create(nil);
          try
            // Attach the iIEBitmap to iImageEnProc
            iImageEnProc.AttachedIEBitmap := iIEBitmap;
            // Resample the file with rfLanczos3 filter and do not maintain the Aspect Ratio
            iImageEnProc.Resample(640, 480, rfLanczos3, False);
            // Create aTImageEnIO to save the iIEBitmap
            iImageEnIO := TImageEnIO.Create(nil);
            try
              // Attach the iIEBitmap to TImageEnIO
              iImageEnIO.AttachedIEBitmap := iIEBitmap;
              // Save the iFileType to iImageEnIO.Params
              iImageEnIO.Params.FileType := iFileType;
              // Show a iImageEnIO.DoPreviews
              if iImageEnIO.DoPreviews([ppAUTO]) then
                // If iImageEnIO.DoPreviews was sucessful then save the file
                iImageEnIO.SaveToFile(iFilename)
              else
                MessageDlg('Could not save ' + iFilename + ' to a file.', mtWarning, [mbOK], 0);
            finally
              // Free the iImageEnIO
              iImageEnIO.Free;
            end;
          finally
            // Free the iImageEnProc
            iImageEnProc.Free;
          end;
        finally
          // Free the iIEBitmap
          iIEBitmap.Free;
        end;
      finally
        Screen.Cursor := crDefault;
      end;
    end;
end;


William Miller
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html