vcanim.gif (8357 bytes)SAA_imagelibFileGetInfo
Home ] Sales ] Products ] Services ] Support ] Downloads ]

 

 


SAA_imagelibFileGetInfo

Gets information about an image file:

  • File format name.
  • File format description.
  • Image information, such as the width, height, and photometric type.

You should always try to get as much information as you need in a single call, because this function actually opens the file and reads its header.

SAA_imagelibFileGetInfo filename formatName description nbData type info

filename

Name of the image file.

formatName

Returns the file format name. Use SAA_imagelibFileGetInfoLength to determine how much memory to allocate to hold the format name.

description

Returns the file description. Use  SAA_imagelibFileGetInfoLength to determine how much memory to allocate to hold the format description.

nb

Number of information types to retrieve.

infoDesc

Array of information types, which specify what image information to retrieve. The image library supports the following information types:

  • SAA_IL_INFO_WIDTH
  • SAA_IL_INFO_HEIGHT
  • SAA_IL_INFO_PHOTOMETRIC
  • SAA_IL_INFO_SAMPLES_PER_PIXEL
  • SAA_IL_INFO_BITS_PER_SAMPLE
  • SAA_IL_INFO_PLANAR_CONFIG
  • SAA_IL_INFO_COMPRESSION
  • SAA_IL_INFO_ORIENTATION
  • SAA_IL_INFO_NB_IMAGES
  • SAA_IL_INFO_PALETTE_SIZE
  • SAA_IL_INFO_SAMPLE_SIZE

info

Returns an array containing the requested image information.Use SAA_AllocAttributeValue to allocate it.

To extract information from the SAA_AttributeValue structures, use the SW_getAttributeValue .

Example

This code fragment shows how to get information for an image file, load the file, apply an effect to it, and save it in another format.

proc SAA_imagelibFileGetInfoExampl { filename } {

	global SAA_Constants

	package require SWU

	package require SW

	set type [SWU_listToCArray [list $SAA_Constants(SAA_IL_INFO_WIDTH) \
		$SAA_Constants(SAA_IL_INFO_HEIGHT) $SAA_Constants(SAA_IL_INFO_PHOTOMETRIC) \
		$SAA_Constants(SAA_IL_INFO_SAMPLES_PER_PIXEL) $SAA_Constants(SAA_IL_INFO_BITS_PER_SAMPLE) \
		$SAA_Constants(SAA_IL_INFO_PLANAR_CONFIG) $SAA_Constants(SAA_IL_INFO_COMPRESSION) \
		$SAA_Constants(SAA_IL_INFO_ORIENTATION) $SAA_Constants(SAA_IL_INFO_NB_IMAGES) \
		$SAA_Constants(SAA_IL_INFO_PALETTE_SIZE) $SAA_Constants(SAA_IL_INFO_SAMPLE_SIZE)] Integer]

# Get image file information.

	SAA_imagelibFileGetInfoLength filename formatLen descriptionLen

	set info [SAA_AllocAttributeValue 11]

	puts "Format length $formatLen"

	puts "Description length $descriptionLen"

	SAA_imagelibFileGetInfo filename formatName description 11 $type $info

# Print out image file information.

	puts "Dimensions : [SW_getAttributeValue [access $info 0]] x [SW_getAttributeValue [access $info 1]]"

	set tmpVal [SW_getAttributeValue [access $info 2]]

	puts -nonewline "Photometric:  "

	switch -exact -- $tmpVal \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_UNDEFINED) { puts "Undefined " } \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_RGB) { puts "RGB "} \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_RGBA) { puts "RGBA "} \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_BGR) {puts "BGR "} \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_ABGR) {puts "ABGR "} \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_CMAP) {puts "Color Map "} \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_GRAY) {puts "Gray Scale "} \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_RED) { puts "Red " } \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_GREEN) {puts "Green "} \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_BLUE) { puts "Blue "} \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_ALPHA) { puts "Alpha " } \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_DEPTH) { puts "Depth " } \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_MASK) { puts "Mask " } \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_YUV) { puts "YUV " } \
		$SAA_Constants(SAA_IL_PHOTOMETRIC_ANY) {puts "Any " } 

	puts "Samples Per Pixel : [SW_getAttributeValue [access $info 3]]"

	puts "Bits Per Sample   : [SW_getAttributeValue [access $info 4]]"

	puts -nonewline "Planar Config : "

	set tmpVal [SW_getAttributeValue [ access $info 5 ]]

	switch -exact -- $tmpVal \
		$SAA_Constants(SAA_IL_PLANARCONFIG_INTERLEAVED) { puts "Interleaved " } \
		$SAA_Constants(SAA_IL_PLANARCONFIG_SEQUENTIAL) { puts "Sequential " } \
		$SAA_Constants(SAA_IL_PLANARCONFIG_SEPARATE) {puts "Separate " }

	puts -nonewline "Compression : "

	set tmpVal [SW_getAttributeValue [ access $info 6 ] ]

	switch -exact -- $tmpVal \
		$SAA_Constants(SAA_IL_COMPRESSION_NONE) { puts "None " } \
		$SAA_Constants(SAA_IL_COMPRESSION_RLE) { puts "Run Length " } \
		$SAA_Constants(SAA_IL_COMPRESSION_LZW) { puts "LZW " } \
		$SAA_Constants(SAA_IL_COMPRESSION_JPEG) {puts "Jpeg " } \
		$SAA_Constants(SAA_IL_COMPRESSION_PACKBITS) { puts "PackBits " }

	puts -nonewline "Orientation : "

	set tmpVal [SW_getAttributeValue [access $info 7]]

	switch -exact -- $tmpVal \
		$SAA_Constants(SAA_IL_ORIENTATION_TOPLEFT) { puts "Top Left " } \
		$SAA_Constants(SAA_IL_ORIENTATION_BOTTOMLEFT) { puts "Bottom Left " } 

	puts "Number Of Images : [ SW_getAttributeValue [ access $info 8] ] "

	puts "Palette Size     : [ SW_getAttributeValue [ access $info 9] ] "

	puts "Sample Size      : [ SW_getAttributeValue [ access $info 10] ]"

# Load the image file.

	set bufferSize [ expr [ SW_getAttributeValue [ access $info 0] ] * \
		[ SW_getAttributeValue [ access $info 1] ] * [ SW_getAttributeValue [ access $info 10] ] ]

	puts "buffer size is $bufferSize"

# Allocate buffer. Usually you don't need to allocate memory for a string if it is
# not longer then 1000 characters. But in our case buffer is too long so it needs to 
# allocated.

	set buffer [SAA_AllocChar $bufferSize]

	puts "buffer is allocated"

	SAA_imagelibFileLoad filename NULL 1 [ SW_getAttributeValue [ access $info 0]] \
		[ SW_getAttributeValue [ access $info 1]] $buffer NULL
		
	puts "Image is loaded" 

# Apply the OilPaint image processor.

	set processor "OILPAINT"

	SAA_imagelibProcExecute processor NULL \
		[SW_getAttributeValue [ access $info 0]] \
		[SW_getAttributeValue [ access $info 1]] \
		$buffer \
		[SW_getAttributeValue [ access $info 0]] \
		[SW_getAttributeValue [ access $info 1]] \
		$buffer

# Save file as JPG.

	SW_setAttributeValue [ access $info 6] $SAA_Constants(SAA_IL_COMPRESSION_JPEG) int

	set fileName "c:/temp/foo.jpg"

	set format "JPEG"

	puts "about to save file"

	SAA_imagelibFileSave fileName format NULL [SW_getAttributeValue [ access $info 0]] \
		[ SW_getAttributeValue [ access $info 1]] 11 $type $info $buffer 0 NULL

	foreach item "$type $info $buffer" {

		SAA_Free $item
	}
}

SAA Index ] Examples SAA calls index ]

copyright Video-Collage Inc.