loading images to a window - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

loading images to a window

Hello!

I finally got my project to work.

Although, it is very slow. Look, First I open a .pcx file
and load it into a buffer. Second I call GetDC(). Then
I encode the image data and put pixel by pixel calling
the SetPixel() function draw this image. With my 650MHz
it is really slow. It takes about a sec for my 640x414
client window. I believe there are one or two ways
to copy data into a window faster.

Let me please know if you know about one.

I know there is the function SetBitmapBits(), but I don't
know how to fill/prepare the buffer.

[green]Reunion[/green]


Comments

  • ColdShineColdShine Posts: 597Member
    First, create a bitmap using the BITMAP structure (maybe there is some newer one...); this will let you directly specify the bitmap pixels memory address (so you can use pointers to directly write into); when you are finished preparing the pixels, you create the bitmap with CreateBitmapIndirect; select it into a DC and do a fast BitBlt to your window. Full stop.
    Well, I know there are more recent ways of creating a bitmap pixel-by-pixel, but this is the one I remember (and the easiest I think).
    _____________________________
    [size=1][b][grey]Cold[/grey][blue]Shine[/blue][/b]
    http://www16.brinkster.com/rafonline[/size]


  • reunionreunion Posts: 12Member
    : First, create a bitmap using the BITMAP structure (maybe there is some newer one...); this will let you directly specify the bitmap pixels memory address (so you can use pointers to directly write into); when you are finished preparing the pixels, you create the bitmap with CreateBitmapIndirect; select it into a DC and do a fast BitBlt to your window. Full stop.
    : Well, I know there are more recent ways of creating a bitmap pixel-by-pixel, but this is the one I remember (and the easiest I think).
    : _____________________________
    : [size=1][b][grey]Cold[/grey][blue]Shine[/blue][/b]
    : http://www16.brinkster.com/rafonline[/size]
    :
    :

    Yes. That's it. I think I am supposed to use a [b]device independent[/b] bitmap, right? I guess so. That means that I have to create a color table (with 256 colors), and write 8-bits long indexes of colors into the single bitplane.

    If anyone care to know how I will have done at the end, post a demand.

    Thanks

    [green]Reunion[/green]



  • reshtareshta Posts: 1Member
    Never use put/get pixel.
    Only BitBlt.
    All very fast. You can make games without DirectX:-)

    If you want to see how I use it
    go to http://www.brigsoft.com

    : Hello!
    :
    : I finally got my project to work.
    :
    : Although, it is very slow. Look, First I open a .pcx file
    : and load it into a buffer. Second I call GetDC(). Then
    : I encode the image data and put pixel by pixel calling
    : the SetPixel() function draw this image. With my 650MHz
    : it is really slow. It takes about a sec for my 640x414
    : client window. I believe there are one or two ways
    : to copy data into a window faster.
    :
    : Let me please know if you know about one.
    :
    : I know there is the function SetBitmapBits(), but I don't
    : know how to fill/prepare the buffer.
    :
    : [green]Reunion[/green]
    :
    :


  • reunionreunion Posts: 12Member
    : Never use put/get pixel.
    : Only BitBlt.
    : All very fast. You can make games without DirectX:-)
    :
    : If you want to see how I use it
    : go to http://www.brigsoft.com
    :

    I would like to use BitBlt, but I need to know how to convert/transfer a bitplane (256 colors, with color table) (that I get form pcx file) to a bitmap.
    It isn't completely clear to me, yet.

    Very well, I have been to your site, but I haven't seen how You used IT. :-(



    [green]Reunion[/green]



  • iamthecodeiamthecode Posts: 45Member
    : Never use put/get pixel.
    : Only BitBlt.
    : All very fast. You can make games without DirectX:-)
    :

    Reshta, Ok. I am curious. I have wanted to start learning game programming and was planning on using Direct X. You stated that you can make games without DX. I would be very interested in learning how to do it in windows without DX. For instance, what include files to use, and can you do sprites as well? I know DX is used to access video memory directly and allows for fast page flips. Could you show me how to do it, or at least give me a starting point? Thanks, Ron


  • Sephiroth2Sephiroth2 Posts: 423Member
    : : Never use put/get pixel.
    : : Only BitBlt.
    : : All very fast. You can make games without DirectX:-)
    : :
    :
    : Reshta, Ok. I am curious. I have wanted to start learning game programming and was planning on using Direct X. You stated that you can make games without DX. I would be very interested in learning how to do it in windows without DX. For instance, what include files to use, and can you do sprites as well? I know DX is used to access video memory directly and allows for fast page flips. Could you show me how to do it, or at least give me a starting point? Thanks, Ron
    :
    :
    Just use the usual functions

Sign In or Register to comment.