[Closed] Newbee question: How to save bitmap RGBA
Hi,
I´m sure this is a quite simple question for you, but it´s my first script ever.
The following line does want I want:
out_bmp = getchannelasmask image_file #node filename:o_path layer:l
It opens the channel “Node” with given properties of path and filename.
What I need is to modify this line so that i can save just the RGBA part of my Imagefile.
(Basicly its an RPF File and I just like to save the “normal” RGBA Part as Tiff File with a Gamma value)
I hope someone could help.
Thank you
Hi André,
Not sure about the rest of your script but let me understand,
you want to save only the alpha of a rendering to a RGB tif file? then make a new bitmap and copy the alpha into it
This cumbersome script will do that (there must be an easier way!)
fn copyalpha source=
(
b=bitmap source.width source.height
for i=0 to source.height-1 do
(
t=#()
l=getpixels source [0,i] source.width
for j=1 to l.count do append t [l[j].alpha,l[j].alpha,l[j].alpha]
setpixels b [0,i] t
)
return b
)
r=render()
x=copyalpha r
display x
Other than that, you could consider using a render element to save you alpha channel out for you. This could also be set up by a script easily
J.
BTW: nice work on the 3Dworld cover!
Thank you very much for your quick reply! And of course thank you for the comment on this cover!
I just want to save the RBG Part of an RPF File as Tiff File.
This part of my script can do this with saving the Node Channel of the same rpf file:
out_bmp = getchannelasmask image_file #node filename:o_path layer:l
I tried around with something like that:
out_bmp = openBitmap image_file filename:o_path
But that doesn´t work. I only would need the command to read the RGB value of a RPF File as easy as the first command above Reads just the Node Channel!
In the Maxscripthelp I found nearly every possible command for G Buffers except the Main RGB values of a Picture.
[left]
[/left]
[left]getChannel <bitmap>
[/left]
[left]Retrieves the g-buffer channel data for the named channel for the pixel specified by 2D coordinate. The chan_name argument specifies the channel identifier, chosen from the following:
[/left]
[left]#zDepth
[/left]
[left]#matID
[/left]
[left]#objectID
[/left]
[left]#UVCoords
[/left]
[left]#normal
[/left]
[left]#unClamped
[/left]
[left]#coverage
[/left]
[left]#node
[/left]
[left]#mask
[/left]
[left]#shaderColor
[/left]
[left]#shaderTransparency
[/left]
[left]#velocity
[/left]
[left]#weight
[/left]
But no info how to just read the “MainImage”. Something like “getBitmap”…
but André, your RGB is stored in the bitmap that you’re processing to get the channels from. I presume you’re rendering the image into a variable, it looks like it’s called ‘image_file’ here. consider this:
r=render channels:#(#zdepth)
z=getchannelasmask r #zdepth
display z
r.filename="c:/temp/myfile.tif"
z.filename="c:/temp/myfileZ.tif"
save r
save z
close r
close z
Hope that helps, if not, how about posting some of your code?
J.
I dont get it working.
Here is the basically script (partly):
image_file = openbitmap str
image_name = getfilenamefile str
out_path.text = getfilenamepath new_path
o_path = sc_roll.out_path.text+"\\"+ image_name + "_mainimage_"+ "L"+l as string+ extension_string
out_bmp = image_file filename:o_path
save out_bmp
close out_bmp
This code here works fine for G-Buffer Channels:
image_file = openbitmap str
image_name = getfilenamefile str
out_path.text = getfilenamepath new_path
o_path = sc_roll.out_path.text+"\\"+ image_name + "_node_"+ "L"+l as string+ extension_string
out_bmp = getchannelasmask image_file #node filename:o_path layer:l
save out_bmp
close out_bmp
I try to add a button in Bobos Channelextractor Script wich just save the RGB part of an RPF or RLA file as Tiff. (Maybee with a gamma correction)
The Orginal Script does only extract the GBuffer Data.
Ok André,
This should do what you want.
f=getOpenFileName()
b=openbitmap f
c=copy b
c.filename=(substring b.filename 1 (b.filename.count-3))+"tif"
save c
Cheers,
Josh.
Perfectly! It works! Fantastic. Thank you so much j-man! You helped me alot. Now I´m quite faster after the renderings are finished. Besides that script: Fantastic images in your portfolio. That are one of the most outstanding archi viz that I have seen! Respect.
A little problem is not yet solved. I render my pictures in 16bit rpf´s. If i open them with the pictureviewer of 3dsmax it “clamps” the areas that are over bright with highly saturated color. Until now I saved all renderings with this pictureviewer as tiff files. With this step the oversaturated “marked” highlights disappeared. Now with this new script it saves the bitmap as like I can see it within max. The saturated areas are saved with it. How can I switch out those “markers” of overbrightend areas within this script?
Heres the currently working code:
o_path = sc_roll.out_path.text+"\\"+ image_name + "_mainimage_"+ "L"+l as string + extension_string
b = image_file
c = copy b
c.filename=o_path
save c
close c
I’m not sure but it sounds like you might have the ‘video colour check’ activated, check your render settings.
This is used to ensure that colours fall within the gamut of video, either PAL or NTSC. Max will either flag the offending pixels with black or white, or scale the saturation or LUMA until they fall within acceptable ranges.
If this isn’t the case, post some images as an example.
And thanks for the compliment!
Josh.