Clan x86

Technical (Development, Security, etc.) => General Programming => Topic started by: wires on June 22, 2006, 08:44:48 PM

Title: BitBlt
Post by: wires on June 22, 2006, 08:44:48 PM
Is there another function similar to this that can draw colored boxes?

I've had a change of plans with my project, and instead of pictures I think I might just want to use colors. :)
Title: Re: BitBlt
Post by: rabbit on June 22, 2006, 09:05:44 PM
http://www.codeproject.com/bitmap/rplcolor.asp
Title: Re: BitBlt
Post by: wires on June 22, 2006, 09:19:24 PM
QuoteWhen I wrote this function my problem was to replace one color by an other on transparent bitmaps. My images were resources bitmaps, which I store in an ImageList for easy transparency.
From the title and first paragraph it says replacing a color.  I don't think this will allow me to draw a square and then color it. :/
Title: Re: BitBlt
Post by: rabbit on June 22, 2006, 09:37:47 PM
Draw the square in black and change its color.  Durrr.
Title: Re: BitBlt
Post by: wires on June 22, 2006, 09:47:04 PM
Bleh, good idea, I'll try that. :)
Title: Re: BitBlt
Post by: MyndFyre on June 23, 2006, 04:13:26 AM
Or just....

DrawRectangle!

http://windowssdk.msdn.microsoft.com/en-us/library/ms534038(VS.80).aspx

The following code assumes you know how to include the GDI+ headers, are using the flat C API, can figure out how to check the status variable, and have the HDC as hDC, int variables x, y, width, and height, and ARGB values foreColor and backColor.

GpGraphics* gfx;
GpStatus status = GdipCreateFromHDC(hDC, &gfx);
// check status

// create line and fill brushes
GpSolidFill* foreBrush, fillBrush;
status = GdipCreateSolidFill(foreColor, &foreBrush);
// check status
status = GdipCreateSolidFill(backColor, &fillBrush);
// check status

// draw the fill
status = GdipFillRectangleI(gfx, fillBrush, x, y, width, height);
// check status
status = GdipDrawRectangleI(gfx, foreBrush, x, y, width, height);
// check status


I highly recommend learning GDI+.  It is a very robust system, and very slick in .NET.  ;)
Title: Re: BitBlt
Post by: wires on June 23, 2006, 02:02:38 PM
I'll look into that, looks like its what I want. :)
Title: Re: BitBlt
Post by: wires on June 23, 2006, 06:13:45 PM
This works.  Thanks for the help. :)


    With lpRect
        .Left = 0
        .Top = 0
        .Right = 50
        .Bottom = 50
    End With

    hbrush = CreateSolidBrush(vbBlack)
    Call FillRect(Picture1.hdc, lpRect, hBrush)
Title: Re: BitBlt
Post by: MyndFyre on June 23, 2006, 06:43:21 PM
Oh, didn't know you were using VB.  :P