Thread: How to access a bitmap as a 2d array?

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    1

    How to access a bitmap as a 2d array?

    I have loaded a 256 color bitmap in an object of CBitmap class, I need to access that bitmap as a two dimensional array. (using for example name[][] subscript). Can anyone please suggest a function or class that would allow me to do that. Secondly would it be possible for me to check the color of each pixel in that array?

    Any help would be appreciated.

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    If you have drawn the bitmap, then you can access it pixel by pixel as a virtual array using the GetPixel() API function, look it up in the help.

    You may need to fiddle a bit if you are using MFC.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    The API function LockResource() will give you a pointer to the data in memory....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dictionary into a 2d Char Array... Problems.
    By Muzzaro in forum C Programming
    Replies: 10
    Last Post: 12-02-2006, 12:34 PM
  2. question about multidimensional arrays
    By richdb in forum C Programming
    Replies: 22
    Last Post: 02-26-2006, 09:51 AM
  3. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  4. how to pass 2D array into function..?
    By IngramGc in forum C++ Programming
    Replies: 2
    Last Post: 10-21-2001, 08:41 AM
  5. 2d Array access by other classes
    By deaths_seraphim in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2001, 08:05 AM