#### Archived

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

# Blt color fill

## Recommended Posts

DDBLTFX ddbltfx;
RECT dest_rect;

memset(&ddbltfx,0,sizeof(ddbltfx));

ddbltfx.dwSize = sizeof(ddbltfx);
ddbltfx.dwFillColor = RGB16(rand()%256,rand()%256,rand()%256);

unsigned short y1 = rand()%SCREEN_HEIGHT;
unsigned short y2 = rand()%SCREEN_HEIGHT;
unsigned short x1 = rand()%SCREEN_WIDTH;
unsigned short x2 = rand()%SCREEN_WIDTH;

dest_rect.bottom = y2;
dest_rect.top = y1;
dest_rect.left = x1;
dest_rect.right = x2;

lpddsprimary->Blt(&dest_rect,NULL,NULL,DDBLT_COLORFILL | DDBLT_WAIT,&ddbltfx);
ok, what it''s telling me is that there are negative values for the coordinates. The program still works without crashing but when you exit it gives you the "this program now has to close" message which is annoying . I made the variables unsigned, shouldn''t that make the negatives go away?

##### Share on other sites
it''s telling you that either bottom is less than top or right is less than left or both. you need to add two if tests to swap the values if that''s the case or re-work the setting of x2 and y2 so that they are never less than x1 and y1 respectively.

• ### Forum Statistics

• Total Topics
628328
• Total Posts
2982098

• 22
• 9
• 9
• 13
• 11