Notifications
Clear all

[Closed] Setting SaveBitmap .tga Un-premultiplied?

I need to save a rendered image as an un-premultiplied TGA file, how can I set the “pre-multiply by alpha” setting using maxscript?


 stitch = getLastRenderedImage()
 stitch.filename = "C:\	est\	est01.tga"
 save stitch
 

The above will result in the image being saved with a pre-multiplied Alpha.

Cheers…

Dave

7 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

stitch = getLastRenderedImage()
old_premult = targa.getPreMultAlpha() -- if you want to keep old 
targa.setPreMultAlpha off -- (as you want)
stitch.filename = "C:\	est\	est01.tga"
save stitch
targa.setPreMultAlpha old_premult -- reset to old
 

Ok found this in the help file and unsure how to use it…

[b][b][color=white][b]Targa : BitmapIO[/b][/color][/b][/b]

 [left][b][b]Targa - superclass: BitmapIO; super-superclass:MAXWrapper - classID: #(6,  0)[/b][/b]
[/left]
 [left][b][b]Constructor[/b][/b]
[/left]
 [left][b][b]Class instances not creatable by MAXScript[/b][/b]
[/left]
 [left][b][b]Aliases:[/b][/b]
[/left]
 [left][b][b]Targa[/b][/b]
[/left]
 [left][b][b]tgaio[/b][/b]
[/left]
 [left][b][color=white][b]Targa interfaces[/b][/color][/b]
[/left]
 [left]Interface: [b][b]itgaio[/b][/b]
[/left]
 [left][b][b]Methods[/b][/b]
[/left]
 [left][b][b]getColorDepth[/b][/b]()
[/left]
 [left]This  method returns the color depth, which would be 16, 24, or 32.
[/left]
 [left][b][b]setColorDepth[/b][/b]  <integer>colorDepth
[/left]
 [left]This  method allows you to set the color depth.
[/left]
 [left][b][b]colorDepth: [/b][/b]The color depth, being  either 16, 24, or 32.
[/left]
 [left][b][b]getCompressed[/b][/b]()
[/left]
 [left]This  method returns [b][b]True[/b][/b] if the compression flag is set, otherwise [b][b]False[/b][/b].
[/left]
 [left][b][b]setCompressed[/b][/b]  <boolean>compression
[/left]
 [left]This  method allows you to set the compression flag.
[/left]
 [left][b][b]compression: True[/b][/b] to set the compression  flag, otherwise [b][b]False[/b][/b].
[/left]
 [left][b][b]getAlphaSplit[/b][/b]()
[/left]
 [left]This  method returns [b][b]True[/b][/b] if the alpha split flag is set, otherwise [b][b]False[/b][/b].
[/left]
 [left][b][b]setAlphaSplit[/b][/b]  <boolean>alphaSplit
[/left]
 [left]This  method allows you to set the alpha split flag.
[/left]
 [left][b][b]alphaSplit: True[/b][/b] to set the alpha split  flag, otherwise [b][b]False[/b][/b].
[/left]
 [left][b][b]getPreMultAlpha[/b][/b]()
[/left]
 [left]This  method returns [b][b]True[/b][/b] if the premultiplied alpha flag is set, otherwise [b][b]False[/b][/b].
[/left]
 [left][b][b]setPreMultAlpha[/b][/b]  <boolean>preMultAlpha
[/left]
 [left]This  method allows you to set the premultiplied alpha flag.
[/left]
 [left][b][b]preMultAlpha: True[/b][/b] to set the premultiplied alpha flag,  otherwise [b][b]False[/b][/b].
[/left]
 [left]<string>[b][b]getAuthor[/b][/b]()
[/left]
 [left]<void>[b][b]setAuthor[/b][/b]  <string>author
[/left]
 [left]The  author name will be clamped to 40 characters
[/left]
 [left]<string>[b][b]getJobName[/b][/b]()
[/left]
 [left]<void>[b][b]setJobName[/b][/b]  <string>jobname
[/left]
 [left]The Job  name will be clamped to 40 characters
[/left]
 [left]<string>[b][b]getComment1[/b][/b]()
[/left]
 [left]<void>[b][b]setComment1[/b][/b]  <string>comment
[/left]
 [left]<string>[b][b]getComment2[/b][/b]()
[/left]
 [left]<void>[b][b]setComment2[/b][/b]  <string>comment
[/left]
 [left]<string>[b][b]getComment3[/b][/b]()
[/left]
 [left]<void>[b][b]setComment3[/b][/b]  <string>comment
[/left]
 [left]<string>[b][b]getComment4[/b][/b]()
[/left]
 [left]<void>[b][b]setComment4[/b][/b]  <string>comment
[/left]
 [left]The  Comments will be clamped to 80 characters
[/left]
 [left]The  methods in this interface can be accessed by specifying the class, interface,  and method. For example: [b][b]targa.itgaio.getType()[/b][/b]. 
[/left]
 [left]MAXScript will automatically search through a class’ interfaces for a  property or method name if the name isn’t found as a class method or property.  This allows you to say: [b][b]targa.getType()[/b][/b].
[/left]
 [left]Providing the fully qualified name of the method results in faster script  execution. Providing the fully qualified name is also safer, as at some point in  time another interface can be could be specified for the class, and a method or  property with the same name could be defined in that interface. Which method or  property is used would then be dependent on the order in which the the  interfaces were searched for the method or property name. 
[/left]
 [left]See also  Class IBitmapIO_Tga, in the SDK Help file accompanying this product.
[/left]
 [left][b][b]See  also[/b][/b]
[/left]
 [left][BitmapIO  Classes]( http://forums.cgsociety.org/BitmapIO_Classes.htm)   
[/left]
 [left][BMP :  BitmapIO]( http://forums.cgsociety.org/BMP_interfaces_.htm)   
[/left]
 [left][JPEG :  BitmapIO]( http://forums.cgsociety.org/JPEG_interfaces_.htm)   
[/left]
 [left][Portable_Network_Graphics  : BitmapIO]( http://forums.cgsociety.org/Portable_Network_Graphics_interfaces_.htm)  
[/left]
 [left][TIF :  BitmapIO]( http://forums.cgsociety.org/TIF_interfaces_.htm)   
[/left]

Pretty simple all you need to do is this:

targa.setPreMultAlpha false
-Eric

1 Reply
(@davewortley)
Joined: 11 months ago

Posts: 0

Where do I use this tho?

And how do I use [b]getPreMultAlpha/b on a file?

I need to test whether I file is set to pre-multipled before I know whether to save it as such or not.

The targa interface changes the settings for file outputs (render saved files, etc). It isn’t used to read data from the format. There is no easy way to read if a file is premultiplied or not, since this isn’t metadata stored in the file. From the help:

The Targa BitmapIO class provides a function published interface for tga I/O that gives access to the type of image to be saved.
-Eric

Cheers guys. Got it working, and of course I guess there is no way to find out whether a TGA was saved pre-mulitplied or not. Shame they didn’t think to put a note in the file.