Author Topic: BitBlt  (Read 5515 times)

0 Members and 1 Guest are viewing this topic.

Offline wires

  • Pwnage
  • x86
  • Hero Member
  • *****
  • Posts: 1103
  • cocaine is fun!
    • View Profile
    • Weapon Of Mass Destruction
BitBlt
« 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. :)

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: BitBlt
« Reply #1 on: June 22, 2006, 09:05:44 pm »

Offline wires

  • Pwnage
  • x86
  • Hero Member
  • *****
  • Posts: 1103
  • cocaine is fun!
    • View Profile
    • Weapon Of Mass Destruction
Re: BitBlt
« Reply #2 on: June 22, 2006, 09:19:24 pm »
Quote
When 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. :/

Offline rabbit

  • x86
  • Hero Member
  • *****
  • Posts: 8092
  • I speak for the entire clan (except Joe)
    • View Profile
Re: BitBlt
« Reply #3 on: June 22, 2006, 09:37:47 pm »
Draw the square in black and change its color.  Durrr.

Offline wires

  • Pwnage
  • x86
  • Hero Member
  • *****
  • Posts: 1103
  • cocaine is fun!
    • View Profile
    • Weapon Of Mass Destruction
Re: BitBlt
« Reply #4 on: June 22, 2006, 09:47:04 pm »
Bleh, good idea, I'll try that. :)

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: BitBlt
« Reply #5 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.
Code: [Select]
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.  ;)
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.

Offline wires

  • Pwnage
  • x86
  • Hero Member
  • *****
  • Posts: 1103
  • cocaine is fun!
    • View Profile
    • Weapon Of Mass Destruction
Re: BitBlt
« Reply #6 on: June 23, 2006, 02:02:38 pm »
I'll look into that, looks like its what I want. :)

Offline wires

  • Pwnage
  • x86
  • Hero Member
  • *****
  • Posts: 1103
  • cocaine is fun!
    • View Profile
    • Weapon Of Mass Destruction
Re: BitBlt
« Reply #7 on: June 23, 2006, 06:13:45 pm »
This works.  Thanks for the help. :)

Code: [Select]
    With lpRect
        .Left = 0
        .Top = 0
        .Right = 50
        .Bottom = 50
    End With

    hbrush = CreateSolidBrush(vbBlack)
    Call FillRect(Picture1.hdc, lpRect, hBrush)

Offline MyndFyre

  • Boticulator Extraordinaire
  • x86
  • Hero Member
  • *****
  • Posts: 4540
  • The wait is over.
    • View Profile
    • JinxBot :: the evolution in boticulation
Re: BitBlt
« Reply #8 on: June 23, 2006, 06:43:21 pm »
Oh, didn't know you were using VB.  :P
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Our species really annoys me.