drawing a bitmap to the screen
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: drawing a bitmap to the screen

  1. #1
    Join Date
    Sep 2010
    Posts
    6

    Post drawing a bitmap to the screen

    hello,

    im playing counter-strike 1.6 and the aiming cross hairs ( the X in the middle of the screen ) is not centered properly

    so im trying to build a console application that would load a bitmap that i created and place it at the coordinates 512,384

    here is what i have of the code untill now..

    #include <windows.h>
    #include <tchar.h>
    int main()
    {
    HDC hdc = CreateCompatibleDC(NULL);
    HBITMAP cross = (HBITMAP)LoadImage(NULL, _T("E:\\cross.bmp") ,IMAGE_BITMAP,0,0, LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
    SelectObject(hdc, cross);
    while (1)
    {
    HDC hdc_x = GetDC(HWND_DESKTOP);
    BitBlt(hdc_x,488,359,48,48,hdc,0,0,LR_LOADFROMFILE);
    ReleaseDC(HWND_DESKTOP,hdc_x);
    }
    return 0;
    }



    my problem with that, is that its not loading the image, and its showing me a black box and not the image

    can somebody help me with this

  2. #2
    Join Date
    Apr 2009
    Posts
    598

    Re: drawing a bitmap to the screen

    BitBlt(hdc_x,488,359,48,48,hdc,0,0,LR_LOADFROMFILE);
    The last argument is not correct. It should be SRCCOPY.
    LR_LOADFROMFILE has a value of 16, which gives the same result as the BLACKNESS flag.

    Besides, the error codes should be tested. See http://www.runicsoft.com/bmp.php

  3. #3
    Join Date
    Sep 2010
    Posts
    6

    Re: drawing a bitmap to the screen

    omg thank you very much !!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center