Storing Bitmaps into an Array
Posted
by Alex Belousov
on October 7th, 2002
Introduction
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 int Add(LPBITMAP pBITMAP); //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
int
iIndex = arrayBitmaps.Add(&bit); //add bitmap to array
...
CBitmap bitStored;
LPBITMAP pBmp = arrayBitmaps.GetAt(iIndex);
//get bitmap from array
if(pBmp != NULL)
bitStored.CreateBitmapIndirect(pBmp);
...

Comments
how can get image of hidden window
Posted by jags_ddit on 03/03/2005 12:30amfirstly, 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?
ReplyCan you show me how to compress a BMP?
Posted by nguyenquang on 04/04/2004 09:31amYour 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
Replywhat is bit?
Posted by Legacy on 11/13/2003 12:00amOriginally posted by: Gauri
ReplyOther option - standard way of saving into bitmap array
Posted by Legacy on 11/07/2003 12:00amOriginally 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);
bitmap.LoadBitmap(IDB_ITEM_ROOT_NOT_SELECTED);
m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
// the delete needed because U already attached this bitmap)
bitmap.DeleteObject();
bitmap.LoadBitmap(IDB_ITEM_ROOT_SELECTED);
m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
bitmap.DeleteObject();
bitmap.LoadBitmap(IDB_ITEM_SUB_ROOT_NOT_SELECTED);
m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
bitmap.DeleteObject();
bitmap.LoadBitmap(IDB_ITEM_SUB_ROOT_SELECTED);
m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
bitmap.DeleteObject();
bitmap.LoadBitmap(IDB_ITEM_NOT_SELECTED);
m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
bitmap.DeleteObject();
bitmap.LoadBitmap(IDB_ITEM_SELECTED);
m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
bitmap.DeleteObject();
bitmap.LoadBitmap(IDB_ITEM_NOT_SELECTED_PATTERN);
m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
bitmap.DeleteObject();
bitmap.LoadBitmap(IDB_ITEM_SELECTED_PATTERN);
m_pimagelist->Add(&bitmap, (COLORREF)0xFFFFFF);
bitmap.DeleteObject();
}
Use standard is an easy way some time.
I hope that this will help
Replyresize bitmap file
Posted by Legacy on 05/13/2003 12:00amOriginally 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
-
-
Reply->
Posted by shekhar_dawer on 01/29/2005 02:09amHello if u know how to resize a bitmap now then pz tell me also thanx
Reply:(
Posted by jabby12 on 07/24/2004 11:35pmI want to know too!
Replyhi..alex
Posted by Legacy on 11/24/2002 12:00amOriginally posted by: maziah
alex...
i'm try to run Carraybitmap in visual C++ but it have some errors as below :
Compiling...
Skipping... (no relevant changes detected)
ArrayBITMAP.cpp
Linking...
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
Replyhow to change bitmap size
Posted by Legacy on 11/21/2002 12:00amOriginally posted by: maziah
-
Replyoh yes
Posted by jabby12 on 07/24/2004 11:37pmIf you have to source code,please give me one ,thanks,alex! my email:jabby12@163.com
ReplyWhat's the difference to vector<CBitmap> ??
Posted by Legacy on 11/05/2002 12:00amOriginally 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?
Greetings
Replynot so bad??
Posted by Legacy on 10/29/2002 12:00amOriginally posted by: Johnthan
CImageList is also a good choice?
ReplyHow to build a DIB from raw data
Posted by Legacy on 10/27/2002 12:00amOriginally 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.
ReplyLoading, Please Wait ...