PDA

View Full Version : Why is my bitmap showing incorrect gamma, here is the code


CerberusC
08-31-2009, 12:31 PM
That's the question, here is the code to generate the bitmap and show it, just do an scen with some spheres (i have the gamma in max activated to 2.2, all in 2.2)

So when i load the bitmap inside the UI Bitmap, it is incorrect :S

here is the code:


rollout BoneTest "Bone Test" width:680 height:640
(
button test1 "test1"
button test2 "test"
local TempBMP = bitmap 320 240 /*gamma:IDisplayGamma.gamma*/ color:red hdr:false hasAlpha:false
bitmap FPrevBMP bitmap:TempBMP pos:[20,250] width:320 height:240
local Temp2BMP = bitmap 320 240 /*gamma:IDisplayGamma.gamma*/ color:red hdr:false hasAlpha:false
local a = ""
local b = ""



fn test =(
FPrevBMP.bitmap = TempBMP
render to:Temp2BMP
Temp2BMP.filename = "c:\\temp.tga"
save Temp2BMP
display Temp2BMP
Temp2BMP = bitmap 320 240 /*gamma:IDisplayGamma.gamma*/ color:red hdr:false hasAlpha:false
gc light:true
)

on test1 pressed do (test() )

fn test22 = (

b = openBitMap "c:\\temp.tga"
FPrevBMP.bitmap = b
close b
b = ""
deleteFile "c:\\temp.tga"
gc light:true
)

on test2 pressed do (test22())

)


CreateDialog BoneTest 680 640 style:#(#style_titlebar, #style_border, #style_sysmenu,#style_mi)




I have the gamma code in the bitmaps commented because it does not help.

Cheers.

CerberusC
08-31-2009, 01:53 PM
Ok, this is working with TIFF or JPG, but not with TGA...some clue why is not working with TGA?



rollout BoneTest "Bone Test" width:680 height:640
(
button test1 "test1"
button test2 "test"
local TempBMP = bitmap 320 240 gamma:IDisplayGamma.gamma color:red hdr:false hasAlpha:false
bitmap FPrevBMP bitmap:TempBMP pos:[20,250] width:320 height:240
local Temp2BMP = bitmap 320 240 gamma:IDisplayGamma.gamma color:red hdr:false hasAlpha:false
local a = ""
local b = ""



fn test =(
FPrevBMP.bitmap = TempBMP
Temp2BMP =render()
Temp2BMP.filename = "c:\\temp.jpg"
save Temp2BMP
display Temp2BMP
Temp2BMP = bitmap 320 240 gamma:IDisplayGamma.gamma color:red hdr:false hasAlpha:false
gc light:true
)

on test1 pressed do (test() )

fn test22 = (
local oldFileInGamma = fileInGamma
fileInGamma = 1.0/(IDisplayGamma.gamma)
local c = openBitmap "c:\\temp.jpg"
FPrevBMP.bitmap = c
fileInGamma = oldFileInGamma
close c
c = ""
deleteFile "c:\\temp.jpg"
gc light:true
)

on test2 pressed do (test22())

)


CreateDialog BoneTest 680 640 style:#(#style_titlebar, #style_border, #style_sysmenu,#style_mi)

MarcoBrunetta
08-31-2009, 02:05 PM
I've dealt with this in the past and it was always a headache, right now I just use a .NET control if at all possible.

CerberusC
08-31-2009, 11:10 PM
It's a real pain, i found the solution this evening, i'm using TGA's to get the alphas and jpg to get the render, it's a mixutre, but i'm creating the files when i need, and deleting the files just after read it, so is no problem...but the maxscript interface to deal with gamma is a bit rude hehe.

I don't know anything of .Net yet, i thing sooner or later i must learn a bit :D

Cheers and thank for the answer.

CGTalk Moderation
08-31-2009, 11:10 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.