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 slice a picture in to the equal parts?

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
guja Posted - Nov 21 2018 : 09:52:47
how can i slice a picture in to the several equal parts (eg. 8x10) and save them to the files?
3   L A T E S T    R E P L I E S    (Newest First)
wesleybobato Posted - Nov 22 2018 : 09:56:39
Hi guja

In Delphi all class parameters or records are pointers.
This means that any changes made to the parameter change the origin.

Example

procedure Image_NotThreadSafe(Image: TImage);
begin
  //It does not matter if the parameter is Param, Const or Var
  //Because I'm passing an object class.

  Image.Picture.Bitmap.SetSize( 0, 0 );
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Image1.Picture.LoadFromFile( 'Tulips.jpg' );
  Image_NotThreadSafe( Image1 );
end;


Note that Bitmap.CopyRectTo, makes only one copy of a region, and does not write or change.
Then it's Thread Safe.

You can write in a bitmap using Thread Safe I do this but one must be careful not to try to write in a region that does not exist!

I recommend reading this page has several examples of how to write to a Bitmap using PPL.

http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Using_the_Parallel_Programming_Library

2. Image Comparison Compare the content of two images side-by-side
https://www.imageen.com/files/demos/run/Display/ImageComp/ImageComp.exe

3. Save without headers? how will you identify after that the Stream is a JPEG or an image file?
guja Posted - Nov 22 2018 : 03:53:00
Thank you!
1. Is this code thread-safe?
2. What is the fastest way to compare two TIEBitmap and determine whether they are the same?
3. Is there way to save outBmp as JPEG to the Stream (without headers)? i use ImageEn 5.2.0
xequte Posted - Nov 21 2018 : 16:03:14
Hi

It would be something like:

// Method that takes an image, splits it into multiple cells and saves each cell to file
procedure SplitImage(Bitmap: TIEBitmap; cols, rows: integer; DestFolder: string);
var
  cellWidth, cellHeight: Double;
  x,y : Integer;
  outBmp: TIEBitmap;
begin
  cellWidth := Bitmap.Width / cols;
  cellHeight := Bitmap.Height / rows;

  outBmp := TIEBitmap.Create;
  outBmp.Allocate( Round( cellWidth ), Round( cellHeight ));

  for x := 0 to cols do
    for y := 0 to rows do
    begin
      Bitmap.CopyRectTo( outBmp,
                         Round( cellWidth * x ), Round( cellHeight * y ),
                         0, 0,
                         Round( cellWidth ), Round( cellHeight ));
      outBmp.Write( IncludeTrailingBackSlash( DestFolder ) + IntToStr( x ) + '_' + IntToStr( y ) + '.bmp' );
    end;

  outBmp.Free;
end;


Nigel
Xequte Software
www.imageen.com