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
 Create Image from Selection
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

izaque

Brazil
95 Posts

Posted - Oct 17 2012 :  11:31:50  Show Profile  Reply
How can I create an image file starting from a selected image with TImageEnView or another ... TImage?

xequte

38182 Posts

Posted - Oct 17 2012 :  21:44:07  Show Profile  Reply
Sorry, I'm not quite following.

Do you mean when you select a portion of the image displayed in a TImageEnView, you want to save that part to a file?



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

izaque

Brazil
95 Posts

Posted - Oct 18 2012 :  04:06:53  Show Profile  Reply
Exactly, I need to select an image, and this selected part want to generate another image, more precisely in TIFF (Selected_image.tif).
Go to Top of Page

w2m

USA
1990 Posts

Posted - Oct 18 2012 :  09:00:16  Show Profile  Reply
Try this:
procedure TForm1.SaveSelection1Click(Sender: TObject);
// Save the selection to a TIFF file
var
  iIEBitmap: TIEBitmap;
  iImageEnIO: TImageEnIO;
  iFilename: string;
begin
  // Test for selection
  if ImageEnView1.Selected then
  begin
    // Create the TIEBitmap to hold the selection
    iIEBitmap := TIEBitmap.Create;
    try
      // Copy the selection to the iIEBitmap
      ImageEnView1.CopySelectionToIEBitmap(iIEBitmap);
      // Create iImageEnIO to save the IEBitmap to a file
      iImageEnIO := TImageEnIO.Create(nil);
      try
        // Set iIEBitmap as the AttachedIEBitmap
        iImageEnIO.AttachedIEBitmap := iIEBitmap;
        // Build the save picture dialog filter
        SavePictureDialog1.Filter := '';
        SavePictureDialog1.Filter := SavePictureDialog1.Filter + 'TIF Bitmap (*.tif; *.tiff)|*.tif;*.tiff|';
        SavePictureDialog1.FilterIndex := IEFileTypeToGraphicFilterIndex(ImageEnView1.IO.Params.FileType);
        SavePictureDialog1.FileName := 'Selection.tif';
        SavePictureDialog1.DefaultExt := '.tif';
        SavePictureDialog1.Title := 'Save Selection As- ' + SavePictureDialog1.FileName;
        if SavePictureDialog1.Execute then
        begin
          if SavePictureDialog1.FileName <> '' then
          begin
            Screen.Cursor := crHourGlass;
            try
              iFilename := SavePictureDialog1.FileName;
              // Set the file type as TIFF
              iImageEnIO.Params.FileType := ioTIFF;
              // Show the IOPreviews Dialog
              if iImageEnIO.DoPreviews([ppAUTO]) then
                // Save the iIEBitmap as a TIFF
                iImageEnIO.SaveToFileTIFF(iFilename);
                // Deselect the selection
                ImageEnView1.DeSelect;
            finally
              Screen.Cursor := crDefault;
            end;
          end;
        end;
      finally
        // Free iImageEnIO
        iImageEnIO.Free;
      end;
    finally
      // Free iIEBitmap
      iIEBitmap.Free;
    end;
  end
  else
  begin
    MessageDlg('Please make a selection.', mtWarning, [mbOK], 0);
  end;
end;


William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

izaque

Brazil
95 Posts

Posted - Oct 19 2012 :  06:11:57  Show Profile  Reply
Try this. Thank you very much!
Go to Top of Page

izaque

Brazil
95 Posts

Posted - Oct 22 2012 :  03:57:29  Show Profile  Reply
Is there any way to select more than one area of the image and transforms it into a single image starting these selections?
Go to Top of Page

w2m

USA
1990 Posts

Posted - Oct 22 2012 :  06:53:11  Show Profile  Reply
After you make a selection, press and hold down the SHIFT key, then make another selection. Then use the code provided to save the tif file. After saving you will have one image with both selections with a white background.

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

izaque

Brazil
95 Posts

Posted - Oct 22 2012 :  09:14:31  Show Profile  Reply
Perfect, thank you!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: