Results 1 to 6 of 6

Thread: Getting colour data from a bitmap

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Getting colour data from a bitmap

    Simple question. How do i do it?

    I've searched the MSDN and here on vbforums, but so far have only found how to load a bmp:
    Code:
    HBITMAP hBmp = (HBITMAP)LoadImage(NULL, "Terrain.bmp", IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR | LR_LOADFROMFILE);
    and how to put it into a device context (which i don't think i want to do.


    What i'm trying to do here is create a terrain generator using a bitmap as the hightmap. I've currently got the engine working, all i need now is a way do get a heightmap in. So i decided on a grey-scale bmp as that seemed the easiest way (creating terrain).


    As always thanks for any help you may provide.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You can get the BITMAP structure of the HBITMAP and read the color data. It's probably the easiest way, unless you're handling a DIB section, in which case you need to use a different way to get the data.

    You can search for image libraries too, there are enough available for free, they allow loading of other images (GIF, JPG, PNG, PCX, ...) too.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Ok, i may be being really dumb here but i added this code:
    Code:
    Bitmap bmp;
    bmp.FromFile("Terrain.bmp");
    with the appropriate includes:

    Code:
    #include <gdiplus.h>
    #include <Gdiplusheaders.h>
    But i get errors about Bitmap being an indeclared identifyer. What am i doing wrong??
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  4. #4
    Frenzied Member aewarnick's Avatar
    Join Date
    Dec 2002
    Posts
    1,037
    You probably need
    using namespace Gdiplus;

  5. #5
    Fanatic Member
    Join Date
    Sep 2000
    Posts
    770
    Here, you can find the file format for bmp's

    http://www.wotsit.org/search.asp

  6. #6

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Thanks for the replys. It works now.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

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



Click Here to Expand Forum to Full Width