[Closed] Modifying the Gamma Of A Bitmap
So I’ve written a little test scrip here:
rollout ui_imgtag "imgtag"
(
local bm = openbitmap "E:\\personal\\1.jpg"
local nbm = bitmap 600 600 color:white gamma:2.2
copy bm nbm
imgtag img_tag "imgtag" bitmap:nbm
)
createdialog ui_imgtag width:1000
If I try and run this, I get an error:
– Compile error: control already defined: bm
– In line: copy bm n
I am trying to copy the bitmap in bm into the gamma modified bitmap nbm, but copy doesn’t seem to be working.
Also, if I change these two variable from local, I get a different error. Which is confusing, since they should work whether they’re local or not.
Anyone know what may be going on here?
- Neil
placing the bitmap assignment into an “on <rollout> open” handler works
rollout ui_imgtag "imgtag"
(
local bm
local nbm
on ui_imgtag open do
(
bm= openbitmap "E:\\personal\\1.jpg"
nbm = bitmap 600 600 color:white gamma:2.2
copy bm nbm
imgtag img_tag "imgtag" bitmap:nbm
)
)
createdialog ui_imgtag width:1000
Oh stupid me, of course I’m running code in a rollout. No wonder it was failing. So here’s a revision:
global bm = openbitmap "E:\\personal\\1.jpg"
global nbm = bitmap 600 600 gamma:2.2
copy bm nbm
rollout ui_imgtag "imgtag"
(
imgtag img_tag "imgtag" bitmap:nbm transparent:(color 257 257 257)
)
createdialog ui_imgtag width:1000
However, it still doesn’t do what I need, which is modifies the gamma of the original bitmap. Maxscript helps says:
It is not possible to change the gamma or pixel aspect of a bitmap once created, though you can copy one bitmap into a newly created one that has a different gamma or pixel aspect to achieve this effect.
But changing the gamma value of the second bitmap doesn’t seem to change the pixel values of the loaded bitmap. Any idea what I might be doing wrong?
- Neil
Here Neil,
rollout ui_imgtag "imgtag" width:600 height:600
(
local bm , nbm
ImgTag img_tag "imgtag" pos:[12,46] width:136 height:14 bitmap:nbm
on ui_imgtag open do
(
local bm = openbitmap "E:\\personal\\1.jpg"
local nbm = bitmap (bm.width) (bm.height) color:white gamma:2.2
pasteBitmap bm nbm [0,0] [0,0]
img_tag.bitmap = nbm
img_tag.height = nbm.height
img_tag.width = nbm.width
ui_imgtag.height = nbm.height
ui_imgtag.width = nbm.width
)
)
createdialog ui_imgtag width:1000
Just noted that i had written “on … create do”, of course that should be “on … open do”
On create is structs only AFAIK…