#How to Wallpaper?
12 messages in this thread
How do you go about doing a pattern fill of a window? What I mean is, like you
can do with the workbench in 3.x with WBPatterns — take an iff image and have
it tiled.
You mean in your program code, or in Windows? To my knowledge, you can't in
Windows; you can only have a bitmap for the desktop background. In your own
program you do something like:
char szAppName[] = "MyWindow";
(this is in WinMain)
HBITMAP hBitmap; HBRUSH hBrush;
WNDCLASS wndclass;
hBitmap = LoadBitmap(hInstance, szAppName); hBrush =
CreatePatternBrush(hBitmap);
..
then, when filling out the Window class structure:
wndclass.hbrBackground = hBrush;
assuming that the bitmap is A) in a resource script, and B) has the same label
as szAppName.
Do you have Petzold's "Programming Windows" btw? very handy.
I could give a rat's, uh, rear end, about Windows. How do you do it
programmatically on the Amiga?
Sorry, I must have misread your original message…
I'm assuming you can get the IFF into memory, and have established a bitmap
structure for it… if you need help with that, say so and I'll go into that
(usually I just use Jim Kent's Jiff.c to load IFFs for me, but it's ancient)…
TileMe(struct Window *TileWin,struct BitMap *TileBitMap,
int sizex, int sizey)
{
int i,j;
struct Rastport *WRP = TileWin->RPort;
struct Rastport TileRP = {0};
InitRastPort(&TileRP);
TileRP.BitMap = &TileBitMap;
/* make sure the window is bigger than the source; sizex and sizey can be
calculated from the TileBitMap structure */
if(TileWin->Height < sizey && TileWin->Width < sizex)
{
for(j = 0;j < TileWin->Height;j += sizey)
{
for(i = 0; i < TileWin->Width;i += sizex)
{
ClipBlit(&TileRP,0,0,WRP,i,j,sizex,sizey,0xff);
}
}
}
That's one way, the first that occurred to me. But, while I was typing it, an
easier method came to mind… Just make an Image, like you do for gadgets…
TileMe(struct Window *TileWin, struct Image *TileImage)
{
int i,j;
for(j = 0;j < TileWin->Height;j += TileImage->Height)
{
for(i = 0;i < TileWin->Width;i += TileImage->Width)
{
DrawImage(TileWin->RPort,TileImage,i,j);
}
}
}
That's probably the best (easiest) way to do it. I had to do similar things for
the gui for a video controller program I did years ago; unfortunately, the
source got dumped when I needed room on my HD some time ago.
Sorry for misunderstanding, before.
Bzzzt – wrong answer. Gotta read that fine print there, Eet. This only works
with a bitmap that's 8 x 8 pixels.
– BobR
(Motorola Inside!)
Bzzzt.. right answer, wrong question, VSpriteR.. I knew it only worked with 8 X
8s.. I completely misread steve's message. I thought he wanted to do a
patterned background fill like you can do from Prefs, only I thought he wanted
to do it in Windows. The Prefs patterns are something like 16 X 16, aren't
they? I forget; it's been awhile since I've used them. I just had Windows on my
mind at the time :/
Anyway, I just sent him an answer that's probably wrong; I also forgot to tell
him he needed to refresh his window afterwards to redisplay his gadgetry, if
any. <sigh>.
Steve,
Ignore Eet's information – it's incorrect (even for Windows).
Basically, you need to a series of blits to copy your tile individually,
adjusting your horizontal and vertical offets in the destination accordingly,
based on the size of the tile image.
Say your tile image is 24 x 24 pixels. You'd blit the first row of tiles to
destination offsets 0,0 ; 24,0 ; 48;0, etc. (watching out for clipping on the
right edge). You'd then blit a second row to dest. offsets 0,24 ; 24,24 ;
48,24 ; etc., again, clipping on the right edge.
You'd repeat this until you've filled the entire height (watching out for
clipping on the bottom edge also).
Hope this helps….
– BobR
(Motorola Inside!)
8P~~~~ g'ahead, be insulting… at least I gave him example code on how to do
it, once I understood his question.
I used ClipBlit() in my example, cause he specified a window, and I figured he
wanted it Intuition friendly, like.
(grumbling… you just wait… I'll show you… <grump, grump>)
BTW, your example code works perfectly … all that need be done is to call
RefreshWindowFrame() afterwards. Thanks.
-sja
Yer welcome. Glad I could help.
So, there's nothing as convenient as giving SetAfPt() a pattern then calling
RectFill() ?
-sja
Closest I can think of is the DrawImage() call I mentioned. Other than that, I
can't think of anything nearly as convenient.