PDA

View Full Version : Setting SaveBitmap .tga Un-premultiplied?


DaveWortley
07-13-2009, 09:26 PM
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:\\test\\test01.tga"
save stitch


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


Cheers...

Dave

DaveWortley
07-13-2009, 09:36 PM
Ok found this in the help file and unsure how to use it...

Targa : BitmapIO

Targa - superclass: BitmapIO; super-superclass:MAXWrapper - classID: #(6, 0)

Constructor

Class instances not creatable by MAXScript

Aliases:

Targa

tgaio

Targa interfaces

Interface: itgaio

Methods

getColorDepth()

This method returns the color depth, which would be 16, 24, or 32.

setColorDepth <integer>colorDepth

This method allows you to set the color depth.

colorDepth: The color depth, being either 16, 24, or 32.

getCompressed()

This method returns True if the compression flag is set, otherwise False.

setCompressed <boolean>compression

This method allows you to set the compression flag.

compression: True to set the compression flag, otherwise False.

getAlphaSplit()

This method returns True if the alpha split flag is set, otherwise False.

setAlphaSplit <boolean>alphaSplit

This method allows you to set the alpha split flag.

alphaSplit: True to set the alpha split flag, otherwise False.

getPreMultAlpha()

This method returns True if the premultiplied alpha flag is set, otherwise False.

setPreMultAlpha <boolean>preMultAlpha

This method allows you to set the premultiplied alpha flag.

preMultAlpha: True to set the premultiplied alpha flag, otherwise False.

<string>getAuthor()

<void>setAuthor <string>author

The author name will be clamped to 40 characters

<string>getJobName()

<void>setJobName <string>jobname

The Job name will be clamped to 40 characters

<string>getComment1()

<void>setComment1 <string>comment

<string>getComment2()

<void>setComment2 <string>comment

<string>getComment3()

<void>setComment3 <string>comment

<string>getComment4()

<void>setComment4 <string>comment

The Comments will be clamped to 80 characters

The methods in this interface can be accessed by specifying the class, interface, and method. For example: targa.itgaio.getType().

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: targa.getType().

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.

See also Class IBitmapIO_Tga, in the SDK Help file accompanying this product.

See also

BitmapIO Classes (http://forums.cgsociety.org/BitmapIO_Classes.htm)

BMP : BitmapIO (http://forums.cgsociety.org/BMP_interfaces_.htm)

JPEG : BitmapIO (http://forums.cgsociety.org/JPEG_interfaces_.htm)

Portable_Network_Graphics : BitmapIO (http://forums.cgsociety.org/Portable_Network_Graphics_interfaces_.htm)

TIF : BitmapIO (http://forums.cgsociety.org/TIF_interfaces_.htm)

PiXeL_MoNKeY
07-13-2009, 09:56 PM
Pretty simple all you need to do is this:targa.setPreMultAlpha false-Eric

DaveWortley
07-13-2009, 10:00 PM
Pretty simple all you need to do is this:-Eric

Where do I use this tho?

And how do I use getPreMultAlpha() on a file?

DaveWortley
07-13-2009, 10:01 PM
I need to test whether I file is set to pre-multipled before I know whether to save it as such or not.

denisT
07-13-2009, 10:06 PM
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:\\test\\test01.tga"
save stitch


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


Cheers...

Dave


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

PiXeL_MoNKeY
07-13-2009, 10:10 PM
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

DaveWortley
07-14-2009, 02:35 PM
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.

CGTalk Moderation
07-14-2009, 02:35 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.