News:

Facebook killed the radio star. And by radio star, I mean the premise of distributed forums around the internet. And that got got by Instagram/SnapChat. And that got got by TikTok. Where the fuck is the internet we once knew?

Main Menu

BitBlt

Started by wires, June 22, 2006, 08:44:48 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

wires

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. :)

rabbit


wires

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. :/

rabbit

Draw the square in black and change its color.  Durrr.

wires

Bleh, good idea, I'll try that. :)

MyndFyre

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.  ;)
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

wires

I'll look into that, looks like its what I want. :)

wires

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)

MyndFyre

Oh, didn't know you were using VB.  :P
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.