[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Slicing an image into even squares ?

Posted on 2003-03-10
7
Medium Priority
?
167 Views
Last Modified: 2010-04-04
Is there a way to have an image devided into a grid (like 4X4) at runtime ?
I want to load an image from loadfile (the user finds the image).  Then the program needs to resize that image to be for eg: 300 x 300 pixels.  That image then needs to be cut up into a grid shape with 4 columns and 4 rows.
Each piece needs to have it's own identity so I can write code to work with them.  Hmmm and I barking up the wrong tree here ?  Is this possible ?

Thanks

Mark
0
Comment
Question by:Mark Brady
7 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 8101644
take a look at: BitBlt()
ziolko.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8101747
or if it must not be so perfomant,
then you can take a look
to the copyrect-method of tcanvas

a sample from the delphi-online help

The following code illustrates the differences between CopyRect and BrushCopy. The bitmap graphic ‘TARTAN.BMP’ is loaded into Bitmap and displayed on the Canvas of Form1. BrushCopy replaces the color black in the graphic with the brush of the canvas, while CopyRect leaves the colors intact.

var
  Bitmap: TBitmap;
  MyRect, MyOther: TRect;
begin

  MyRect := Rect(10,10,100,100);

  MyOther := Rect(10,111,100, 201);
  Bitmap := TBitmap.Create;
  Bitmap.LoadFromFile('c:\windows\tartan.bmp');
  Form1.Canvas.BrushCopy(MyRect, Bitmap, MyRect, clBlack);
  Form1.Canvas.CopyRect(MyOther,Bitmap.Canvas,MyRect);
  Bitmap.Free;
end;

meikl ;-)
0
 
LVL 9

Accepted Solution

by:
ITugay earned 150 total points
ID: 8101877
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Expert Comment

by:ILE
ID: 8107486
all u need is to use

procedure StretchDraw(const Rect: TRect; Graphic: TGraphic);



wery easy for example


form1.canwans.stretchdraw(rect(10,20,10,20),graphic1));


where graphic1 is any tgraphic :))


0
 
LVL 3

Expert Comment

by:ILE
ID: 8107499
all u need is to use

procedure StretchDraw(const Rect: TRect; Graphic: TGraphic);



wery easy for example


form1.canwans.stretchdraw(rect(10,20,10,20),graphic1));


where graphic1 is any tgraphic :))


0
 
LVL 3

Expert Comment

by:ILE
ID: 8107545
UPPSSSS

i wrote wrong coordinats

rect comand will not work like i wrote here



yep and if u have a picture int the image1 component u mey write

put something like

form1.canwans.stretchdraw(rect(10,20,30,30),image1.picture.graphic));

see the picture :))



0
 
LVL 20

Author Comment

by:Mark Brady
ID: 8143987
We're still working on this one but it's along the right track.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
Suggested Courses

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question