#### Archived

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

# Colorfill seems to ignore destination rectangle...

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

## Recommended Posts

Why? here's the code

void
colorRect(RECT *pRectDst,int w,int h,unsigned short c)
{
if(pRectDst == 0 ||
w < 0      ||
h < 0      ||
c < 0      ||
w > 640    ||
h > 480) // this is all to limit the range of the surface we can color

return;
ddbfx.dwFillColor = c;
RECT rc = {1280-w,1280-h,1280,1280}; // the surface we're about to color is 1280x1280, so to get the bottom right corner rect of width w and height h, the left and top are just 1280 minus the width and height

pS2->Blt(&rc,0,0,DDBLT_COLORFILL,&ddbfx); // HERE IS THE PROBLEM. i'm telling it to fill with the color just the destination rect but it fills the whole freaking surface

pS1->Blt(pRectDst,pS2,&rc,DDBLT_KEYDESTOVERRIDE,&ddbfx); // now we blit the colored rect from ps2 to ps1 (the back buffer) using destination color keying (so only white is written to). this SHOULD give the effect of making any white pixels in the destination rectangle on the back buffer the same color as the rect we filled with color c on surface ps2. But NOOO it doesn't want to do that.

}

The reason i'm doing all of that (make a rect fill it with color, blit that rect on top of something else to fill in white spaces with the color) is because when i tried doing this sort of thing in one blit call (colorfill and destcolorkey at the same time) it just filled in the entire backbuffer with the color. Like it still does now. Is there something really obvious I'm missing here? This is driving me insane and has for months now. If i don't solve it i think spontaneous combustion is imminent. save yourselves. save me. you're my only hope. *edit* i even made a graphical description of what I'm talking about: [edited by - Irrelevant on March 31, 2003 11:23:50 PM]

##### Share on other sites
no ideas? hunches? incantations?

##### Share on other sites
I fixed it (sort of)!
I had to set the fill color back to 0 after I set it to the fill color initially.
So, I''ll leave this up in the event that someone, someday, has the same difficulty as I.
The Irrelevant Method is what I''ll call it.
Brilliant.

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633742
• Total Posts
3013636
×