[Closed] Bitmap dimensions in SDK
I’ve written a simple maxscript extension which takes bitmap image as input and calculates withs width. Sound really simple, doesn’t it? Here is the main part of the code. Correct paths for sdk lib and include folders have been set. I’ve used #include “BitMaps.h” to be able to use MAXBitMap.
Value* drawBitmap_cf(Value **arg_list, int count) {
MAXBitMap* mbm = (MAXBitMap*)arg_list[0];
BitmapInfo *bi = &mbm->bi;
int bWidth = bi->Width();
return &true_value;
}
When I try to build the project I get following error:
drawBitmap.obj : error LNK2001: unresolved external symbol “__declspec(dllimport) public: unsigned short __thiscall BitmapInfo::Width(void)” (_imp?Width@BitmapInfo@@QAEGXZ)
I dont have the slightest idea of what causes it or how to fix it. So please, does anybody have a working example of extracting width and height of bitmap in sdk?
Nope, I hadn’t… So it was that easy sollution! Thank you! I had been trying to solve it for few hours already =D
Okey, second problem. Bitmap::Width() always returns me zero (0). How can I obtain width of bitmap image in max sdk because Bitmap and BitmapInfo classes does not seem to work?
Here’s an example of how to get the width and height of a bitmap:
Value *GetBitmapInfo_cf(Value **arg_list, int count)
{
check_arg_count(GetBitmapInfo, 1, count);
if (!is_bitmap(arg_list[0]))
return &false_value;
MAXBitMap *maxBM = (MAXBitMap *)arg_list[0];
CharStream *out = thread_local(current_stdout);
out->printf("Width = %d
Height = %d
", maxBM->bi.Width(), maxBM->bi.Height());
return &true_value;
}
And then, if for example you have a bitmap assigned to the diffuse map slot (in the first slot of the material editor)…
getBitmapInfo mEditMaterials[1].diffuseMap.bitmap
Hope that helps.
Unfortunately it doesn’t. I copypasted your code and complied it. Here is the result:
myBitmap = meditMaterials[1].diffuseMap.bitmap
BitMap:C:\Graphics\3ds Max 9\maps\Concrete.Cast-In-Place.Flat.Grey.1.jpg
GetBitmapInfo myBitmap
Width = 0
Height = 0
true
Thats from maxscript listener. I have no idea why it still keeps returning zeros…
Thx anyway, I appreciate your efforts.
I’m using MS visual studio 2005 and max 9 sdk if that matters. Is this bug in the sdk or what? I can’t think of any other reasons for it not working…
Yeah, I tested that code in MAX8 and MAX9 using VS2005 and it does its job with no problems. So I have no idea what’s going on there. Have you tried with other bitmaps and formats?. Although this shouldn’t be a problem if MAX is able to load and show the bitmap.
Would it be possible for me to have your visual studio project files? It’d help me alot.
Of course.
Before you compile, go to project properties and with “All Configurations” selected, change the directories for the options: “General -> Output Directory”, “C/C++ -> General -> Additional Include Directories” and “Linker -> General -> Additional Library Directories”. I think it’s all you have to change.
Hope that helps.
Okey, I managed to find out what was wrong. If you use following settings it doesn’t work:
Character Set: Use Unicode Character Set
Whole Program Optimization: Use Link Time Code Generation
C/C++ – Optimization: Maximize Speed (/O2)
And then disable the few necessary things that wont work with these settings.
Simply changing Character Set to Multi-Byte fixes it.
Thx for your help!