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
 Filling shapes with an image
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Scally

6 Posts

Posted - Apr 22 2018 :  10:59:53  Show Profile  Reply
Is it possible to place an image inside polygon, circle, rect and other closed shapes? The fill is not color, but iebitmap, so that the images do not go beyond the shape.

xequte

38186 Posts

Posted - Apr 22 2018 :  19:47:42  Show Profile  Reply
Hi

Probably the easiest way is to add a layer mask to your image, See the LayersEditing\LayerMask demo:



You can make your mask, for example, by creating a shape layer and converting it to a mask layer. Something like:

procedure Tfmain.btnAddShapeMaskClick(Sender: TObject);
var
  prevLayer: TIELayer;
begin
  // Create a star shape, Fill area will be black for now
  ImageEnView1.LayersInsert( ImageEnView1.LayersCurrent + 1, iesStar5 );
  ImageEnView1.CurrentLayer.FillColor    := clBlack;
  ImageEnView1.CurrentLayer.BorderWidth  := 0;

  // Convert shape layer to an image layer
  ImageEnView1.CurrentLayer.ConvertToImageLayer( 1 );

  // Make 256 color and negative (so black becomes white transparency
  TIEImageLayer( ImageEnView1.CurrentLayer ).Bitmap.PixelFormat := ie8g;
  ImageEnView1.Proc.Negative();

  // Set this layer as a mask
  ImageEnView1.CurrentLayer.IsMask := True;

  // Layer must be hidden to work as mask
  ImageEnView1.CurrentLayer.Visible := False;

  // Make it the cover the underlying image
  prevLayer := ImageEnView1.Layers[ ImageEnView1.LayersCurrent - 1];
  ImageEnView1.CurrentLayer.PosX   := prevLayer.PosX;
  ImageEnView1.CurrentLayer.PosY   := prevLayer.PosY;
  ImageEnView1.CurrentLayer.Width  := prevLayer.Width;
  ImageEnView1.CurrentLayer.Height := prevLayer.Height;
end;





Nigel
Xequte Software
www.imageen.com

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