:: My another contributions in Delphi

»Delphi3000.com
posting and uploading delphi articles
[currently as Top 66 uploader]


»Komunitas Delphi Indonesia
starting as a member

Saturday, February 03, 2007

Another Way to Draw Tiled Image to a Canvas

:: Counted Tile Image Draw ::

Question/Problem/Abstract:

How we can get a counted tiling image on a canvas ?
counted as TileX (Horizontally = columns) and TileY(Vertically = lines)
Eg: TileX = 3, TileY = 3, so we can get a 3x3 tiled image on a canvas

Answer:

procedure CountedTileImage(const aPicture: TPicture;
const aTileX, aTileY: Integer; destCanvas: TCanvas;
const destWidth, destHeight: Integer);
var x, y, tx, ty: integer;
src, dst: TBitmap;
myRect: TRect;
begin
if (not aPicture.Graphic.Empty) and (aPicture.Graphic <> nil) then
begin
src := TBitmap.Create;
try
src.Assign(aPicture.Graphic);
dst := TBitmap.Create;
try
dst.Width := aTileX * aPicture.Graphic.Width;
dst.Height := aTileY * aPicture.Graphic.Height;
y := 0;
ty := 1;
while (ty <= aTileY) do begin
x := 0;
tx := 1;
while (tx <= aTileX) do begin
myRect := Rect(x, y, x+src.Width, y+src.Height);
dst.Canvas.CopyRect(myRect, src.Canvas, Rect(0, 0, src.Width, src.Height));
x := x + src.Width;
tx := tx + 1;
end;
y := y + src.Height;
ty := ty + 1;
end;
finally
destCanvas.StretchDraw(Rect(0,0,destWidth,destHeight), dst);
dst.Free;
end;
finally
src.Free;
end;
end;
end;


Have a good time

Sunday, January 21, 2007

Zoom-In and Zoom-Out Text in a TRichEdit
[Undocumented Feature of TRichEdit]

Question/Problem/Abstract:

» How to do Zoom-In and Zoom-Out Text like in MS-Word

Answer:

To do zoom(in/out) of a Text
we can use TRichEdit.
TRichEdit in Default, has the ability to Zoom-In or Zoom-Out all the text within (but only in Run-Time)

So, the steps :
1. Put TRichEdit on the Form
2. Type your text in it (in TRichEdit)
3. Compile your application
4. To do Zoom-In / Zoom-Out,
just Click the left button mouse
combine with mouse-scroll-up or mouse-scroll-down
5. Look at the result/effect to the text in the TRichEdit


ps: I use Delphi 7. But i think, it'll work too with previous version

----------------
Have a good time.

copy of this article is located @ http://www.delphi3000.com/articles/article_4648.asp