Storing Bitmaps into an Array


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

Environment: VC6, NT4


The CArrayBITMAP class stores a Windows bitmap and provides member functions to manipulate the bitmap's array.

Bitmaps are stored in an array with elements such as a BITMAP structure. This class is recommended for temporary image storage. Bitmaps may be any standard type and size. The quantity of kept images is limited to the system's memory size and maximal size of type integer.

This class has the following public functions for its use:

//add new bitmap from object CBitmap, return Bitmap Index in array
int Add(CBitmap * pCBitmap);
//add new bitmap from pointer
//get bitmap's count in array
int GetSize();
//replace bitmap by index
BOOL Replace(int iIndex, LPBITMAP pBITMAP);
//remove bitmap from array by index
BOOL Remove(int iIndex);
//remove all bitmaps from array
void RemoveAll();
//return pointer to bitmap in array (get bitmap)
LPBITMAP GetAt(int iIndex);

Example of This Class's Use

CArrayBITMAP arrayBitmaps;
CBitmap m_bitmap;

     m_bitmap.LoadBitmap(OBM_MYBIT);     //load from resources
  iIndex = arrayBitmaps.Add(&bit);       //add bitmap to array


CBitmap bitStored;
LPBITMAP pBmp = arrayBitmaps.GetAt(iIndex);
//get bitmap from array
    if(pBmp != NULL)


Download source - 3.32 Kb


  • how can get image of hidden window

    Posted by jags_ddit on 03/03/2005 08:30am

    firstly, I thanks to him which had put this artical.This artical had provide me very interesting needed help. now I want to grab the hiden window by Knowing it HWND parameter but i can grab it completely can any one can give me some guide so that i can do it?

  • Can you show me how to compress a BMP?

    Posted by nguyenquang on 04/04/2004 04:31pm

    Your code is good! Now I know how to store BMP into an array. Do you know how to compress a BMP using Facsimile compression algorithm? Please contact me at:ngnguyenquang@yahoo.com

  • what is bit?

    Posted by Legacy on 11/13/2003 08:00am

    Originally posted by: Gauri

    HI Alex,

    I was looking at this example:
    Where is bit defined because it is used in this line
    int iIndex = arrayBitmaps.Add(&bit); //add bitmap to array

    Also I would like to know whether we can use standard function like StretchBlt or BitBlt to display the iamges stored in the array using this example. Can you give a short example.

    And is there any way to display multiple bitmaps simultaneously . My project requires that the bitmap images selected by the user from a folder should be dispalyed at the same time in a grid like structure.

  • Other option - standard way of saving into bitmap array

    Posted by Legacy on 11/07/2003 08:00am

    Originally posted by: Arie

    Why not using a standar way of saving an image into a list, array which has all the neded functionality
    Here is a small example that ilustrate ny idea :
    NOTE : all the IDB_... are a resource IDS that can be cahged to read from file into a CBitmap structure.

    CImageList* m_pimagelist ;

    void CMyClass::SetBitmapsArray()
    CBitmap bitmap;

    m_pimagelist = new CImageList();
    m_pimagelist->Create(18, 16, ILC_MASK, 4, 2);

    m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
    // the delete needed because U already attached this bitmap)
    m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
    m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
    m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
    m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
    m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
    m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
    m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);

    Use standard is an easy way some time.

    I hope that this will help

  • resize bitmap file

    Posted by Legacy on 05/13/2003 07:00am

    Originally posted by: michelle

    can anyone tell me how to resize the bitmap file . i load bitmap file which is 632*324(too big) and wanna to resize it to 92 *112...... i do not know how to do it ...plz help thank

    • ->

      Posted by shekhar_dawer on 01/29/2005 10:09am

      Hello if u know how to resize a bitmap now then pz tell me also thanx

    • :(

      Posted by jabby12 on 07/25/2004 06:35am

      I want to know too!

  • hi..alex

    Posted by Legacy on 11/24/2002 08:00am

    Originally posted by: maziah

    i'm try to run Carraybitmap in visual C++ but it have some errors as below :
    Skipping... (no relevant changes detected)
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
    libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/ArrayBITMAP.exe : fatal error LNK1120: 3 unresolved externals
    Error executing link.exe.

    ArrayBITMAP.exe - 4 error(s), 0 warning(s)

    perphaps, you will help me to make sure it works succesfully.best regard and thank u

  • how to change bitmap size

    Posted by Legacy on 11/21/2002 08:00am

    Originally posted by: maziah

    hi alex...
    i have a problem how to change bitmap size( example from 512x256 image to 128x128) and then convert bmp image to array in c code.would you help me, alex... i need that source code as soon as possible..thanks alex.

    • oh yes

      Posted by jabby12 on 07/25/2004 06:37am

      If you have to source code,please give me one ,thanks,alex! my email:jabby12@163.com

  • What's the difference to vector<CBitmap> ??

    Posted by Legacy on 11/05/2002 08:00am

    Originally posted by: efi

    Maybe it's just that I'm missing something here - anyhow - I was wondering what's the big point compared to the vector<CBitmap> solution?


  • not so bad??

    Posted by Legacy on 10/29/2002 08:00am

    Originally posted by: Johnthan

    CImageList is also a good choice?

  • How to build a DIB from raw data

    Posted by Legacy on 10/27/2002 07:00am

    Originally posted by: jeff

    Here I need some help.

    In photoshop,we can store a image into raw format.In this

    format, all the data in the file is the image data itself.

    That is if a image is 8-bit with the size of 512*512,then

    the size of the file is 512*512 byte.

    My question is that how can I develope a program to read

    the raw format file and create a CDIB class? The problem is

    how to fill the image data into the class? I think there

    must to do some convertions.For example,in DIB,the width

    of a line should be divided by 4.

    Can any expert help me?

    Thanks a lot.

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date