3ds max 2020
* The EXR image file is located in in the same directory with the 3ds max file in this case.
from MaxPlus import BitmapManager image_file_path = r'BG_park_A.exr' bmp_storage = MaxPlus.Factory.CreateStorage(17) bmp_info = bmp_storage.GetBitmapInfo() bmp_info.SetName(image_file_path) bmp = BitmapManager.Load(bmp_info) bmp.Display()
Script explanation line by line:
And it may very well be that I simply didn’t find the correct way it should be done..
I couldn’t find any other way to independently initiate the BitmapInfo object needed for loading the image, other than Initiating a BitmapStorage object and getting referece to its BitmapInfo object. (the BitmapInfo class has no constructor..)
that the 17 integer argument we supply sets the storage to be compatible with:
32-bit floating-point color depth format (without an alpha channel).
See list of other color format options in this example here:
* They wrote a class containing convenient named constants of the integer arguments (see example code below).
* In this example of creating the BitmapStorage just as a way to generate a BitmapInfo object the actual format you’l supply doesn’t matter, but you can’t use a format that can’t be written to like 8 for example (see list below)
Example code for a BitmapStorage format constants container class:
* This example’s source is in the 3ds max help Python examples:
class BitmapTypes(object): BMM_NO_TYPE = 0 # Not allocated yet BMM_LINE_ART = 1 # 1-bit monochrome image BMM_PALETTED = 2 # 8-bit paletted image. Each pixel value is an index into the color table. BMM_GRAY_8 = 3 # 8-bit grayscale bitmap. BMM_GRAY_16 = 4 # 16-bit grayscale bitmap. BMM_TRUE_16 = 5 # 16-bit true color image. BMM_TRUE_32 = 6 # 32-bit color: 8 bits each for Red, Green, Blue, and Alpha. BMM_TRUE_64 = 7 # 64-bit color: 16 bits each for Red, Green, Blue, and Alpha. BMM_TRUE_24 = 8 # 24-bit color: 8 bits each for Red, Green, and Blue. Cannot be written to. BMM_TRUE_48 = 9 # 48-bit color: 16 bits each for Red, Green, and Blue. Cannot be written to. BMM_YUV_422 = 10 # This is the YUV format - CCIR 601. Cannot be written to. BMM_BMP_4 = 11 # Windows BMP 16-bit color bitmap. Cannot be written to. BMM_PAD_24 = 12 # Padded 24-bit (in a 32 bit register). Cannot be written to. BMM_LOGLUV_32 = 13 BMM_LOGLUV_24 = 14 BMM_LOGLUV_24A = 15 BMM_REALPIX_32 = 16 # The 'Real Pixel' format. BMM_FLOAT_RGBA_32 = 17 # 32-bit floating-point per component (non-compressed), RGB with or without alpha BMM_FLOAT_GRAY_32 = 18 # 32-bit floating-point (non-compressed), monochrome/grayscale BMM_FLOAT_RGB_32 = 19 BMM_FLOAT_A_32 = 20
Reading pixel values from the image:
bmp_storage = bmp.GetStorage() hdr_pixel = bmp_storage.GetHDRPixel(3000,200) print(hdr_pixel)
* in this case, writing over the BitmapStorage object we created earlier just to get the BitmapInfo object..
When copying and pasting a script from this example, the indentation may not be pasted correctly.