#### Archived

This topic is now archived and is closed to further replies.

# draw a pattern with mirroring

This topic is 6300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi everyone, i have a little problem hehe The thing is that i want to draw a pattern to a surface but flipped.. vertical and/or horizontal. I found out that if you do a DXDraw.Surface.Draw( ... ) and flip the Rect (sent as parameter) you should get this result that i want, but it flips the whole source surface (thats the whole TPictureCollectionItem) before it draws the pattern. That makes the pattern index not to be "valid" anymore . Sample : // This one works, no flipping is done. Rect1 := ImageList.Items[ IndexIWant ].PatternRects[ Pattern ]; DXDraw.Surface.Draw( PosX, PosY, Rect1, ImageList.Items[ IndexIwant ].PatternSurfaces[ Pattern ], ImageList.Items[ IndexIwant ].Transparent ); But if i flip the rect''s left and right i should get a horizontal flip on the pattern. But as i said it flips the whole ImageList.Items[ IndexIwant ] So if i wanted to draw pattern 0 it draws the last pattern on the same ROW. If someone dont understand, just say the word and ill try to explain more. // Tommy "QuazzeMan" Jonsson

##### Share on other sites

It may require using DrawStretch() since DelphiX passes a TRect as the Surface...

##### Share on other sites
Hmm i tried that, didn't work.

After a few hours of work i made this procedure that will do
this, but you need 2 extra surfaces that are atleast
the size of the patterns you want to draw. They are called
BSurface and CSurface.
Dont ask me why you need the 2 extra, just know if you try
to do this without them it get BUGGY.
mail me at Quazze@krang.net

Btw, the TDDBltFX is in DirectDraw unit.

Procedure DrawFlip( ImageList: TDXImageList; PosX,PosY: Integer; Index,Pattern: Integer; FlipLR,FlipTB: Boolean );Var DFX   : TDDBltFX;    PW,PH : Integer;Begin PW := ImageList.Items[Index].PatternWidth; If PW = 0 Then  PW := ImageList.Items[Index].Picture.Width; PH := ImageList.Items[Index].PatternHeight; If PH = 0 Then  PH := ImageList.Items[Index].Picture.Height; FillChar( DFX, SizeOf(DFX), 0 ); DFX.dwSize := SizeOf(DFX); If FlipLR Then  DFX.dwDDFX := DFX.dwDDFX or DDBLTFX_MIRRORLEFTRIGHT; If FlipTB Then  DFX.dwDDFX := DFX.dwDDFX or DDBLTFX_MIRRORUPDOWN; BSurface.Fill( 0 ); ImageList.Items[Index].Draw( BSurface, 0, 0, Pattern ); CSurface.Fill( 0 ); CSurface.Blt( Rect(0,0,PW,PH), Rect(0,0,PW,PH), DDBLT_KEYSRC or DDBLT_WAIT or DDBLT_DDFX, DFX, BSurface ); CSurface.Fill( 0 ); CSurface.Blt( Rect(0,0,PW,PH), Rect(0,0,PW,PH), DDBLT_KEYSRC or DDBLT_WAIT or DDBLT_DDFX, DFX, BSurface ); DXDraw.Surface.Draw( PosX, PosY, Rect(0,0,PW,PH), CSurface, True );End;

// Tommy "QuazzeMan" Jonsson

Edited by - QuazzeMan on July 20, 2001 6:44:42 PM

##### Share on other sites
That should make for a good addtion to UnDelphiX It''s pretty easy to add functionality to a DXImageList. just derive a control from it...

I still think you could do something with flipping the entire surface and "refigure" where the correct pattern is.

But your solution seems to work... Good job...

##### Share on other sites
First, excuse my totaly mumbojumbo down here, if you cant
figure out what i mean its probobly becouse im very tired,
and explaining when tired its not good..

Well i tried the flipping the whole surface thing and
figuring out where the pattern is, but DXImageList.Item
(TPictureCollectionItem) doesnt have 1 surface for the
whole image (the picture loaded into it). It devides that
image into several surfaces, so if you want to draw the
whole image (as far as i know) you have to draw all the
patterns, i tried this :

DXDraw.Surface.Draw( 0, 0, Rect(0,0,ImageWidth,ImageHeight), imagelist.items[0].patternsurfaces[0], True )

and i dont get the whole bitmap, only 560x560 pixels of it.
(depends on the patternsize, i had a 800x600 image with
patternwidth,patternheight 80 and i got 7x7 (7 rows 7 cols)patterns the
rest of the patterns showed up when i specified patternsurfaces[7] or greater) so you have to figureout what surface to look on
first.. well, try this to see an example of above :

Load a DXG (atleast 800x600) into a imagelist (with patternwidth and height specified),
Do the DXDraw.Surface.Draw thinge
and you will see what i mean.

well, im tired.
See you all later.

// Tommy

Edited by - QuazzeMan on July 21, 2001 12:55:55 AM

1. 1
Rutin
33
2. 2
3. 3
4. 4
5. 5

• 11
• 13
• 86
• 11
• 10
• ### Forum Statistics

• Total Topics
632972
• Total Posts
3009610
• ### Who's Online (See full list)

There are no registered users currently online

×