Re: Converting Bitmap into 2D-Array
"Lucress Carol" <incognito.me@gmx.de> ha scritto nel messaggio
news:66109472-8c8d-4c37-bc40-d1343dfbf3f8@b29g2000hsa.googlegroups.com...
I can't managed to compile the function ExtractGrayScaleFromImage.
the compiler is complaining about image (not declared identifier) and
ASSERT
although I inserted the following include files:
#include <stdio.h>
#include <assert.h>
#include <vector> (maybe I'm missing something else)
To encounter the mistakes I also included the windows include file and
changed the definition
of ExtractGrayScaleFromImage like this:
void ExtractGrayScaleFromImage(
IN HBITMAP hbitmap,
OUT Matrix2D<float> & grayData )
ASSERT is defined for MFC projects.
I did a test project using MFC, so ASSERT was available.
If you don't want to use MFC, you may use ATLASSERT instead of ASSERT (or
you can use _ASSERTE, #defined in <crtdbg.h>).
My code uses CImage, a useful class that you can use also in non-MFC project
(being it an ATL class).
You need to #include <atlimage.h> to use CImage.
You can't substitute CImage with HBITMAP in ExtractGrayScaleFromImage,
because HBITMAP is just an handle, and does not have GetWidth and other
methods I called on CImage instance.
Is it possible that CImage is specific for Microsoft Visual studio
2008?
I think that CImage was available also in VC7.1 (VC++2003).
Unfortunately, if you are using VC6, I don't know if CImage is availbale...
maybe it is not.
However, I would suggest to move to a new recent version of Visual Studio,
a version from the new millenium :)
I belive that VC6 has a great IDE, and very useful wizards for MFC
development (which for reasons unknown to me Microsoft has killed in next
version of the IDE ?!).
However, if you don't use MFC, you should really consider using at least
VC++2008 Express, or better VC++2008 Professional.
You will have a great C++ compiler, a very good STL implementation (instead,
with VC6 version of STL you need to use STLport, or apply Dinkumware
patches), etc.
However, if you really want to still use VC6, I think that you can download
and use a very good image class implementation, called CxImage:
http://www.codeproject.com/KB/graphics/cximage.aspx
HTH,
Giovanni