Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
LoadPsdChannel Method
See Also  Example
Leadtools.Codecs Namespace > RasterCodecs Class : LoadPsdChannel Method



fileName
A String containing the name of the image file to load.
bitsPerPixel

Resulting image pixel depth. Valid values are:

ValueMeaning
0Keep the original file's pixel depth (Do not convert).
1 to 8The specified bits per pixel in the resulting image.
1212 bits per pixel in the resulting image.
1616 bits per pixel in the resulting image.
2424 bits per pixel in the resulting image.
3232 bits per pixel in the resulting image.
4848 bits per pixel in the resulting image.
6464 bits per pixel in the resulting image.

order
The desired color order.
channelIndex
Index of the channel to load. This index is zero-based. Pass 0 to load the first channel, 1 to load the second channel, etc.
channelInfo
a CodecsPsdChannelInfo object to be updated with information about the loaded channel. Pass a null reference (Nothing in Visual Basic) for this parameter if channel information is not needed.
Loads the specified channel from the specified PSD file.

Syntax

Visual Basic (Declaration) 
Public Function LoadPsdChannel( _
   ByVal fileName As String, _
   ByVal bitsPerPixel As Integer, _
   ByVal order As CodecsLoadByteOrder, _
   ByVal channelIndex As Integer, _
   ByVal channelInfo As CodecsPsdChannelInfo _
) As RasterImage
Visual Basic (Usage)Copy Code
Dim instance As RasterCodecs
Dim fileName As String
Dim bitsPerPixel As Integer
Dim order As CodecsLoadByteOrder
Dim channelIndex As Integer
Dim channelInfo As CodecsPsdChannelInfo
Dim value As RasterImage
 
value = instance.LoadPsdChannel(fileName, bitsPerPixel, order, channelIndex, channelInfo)
C++/CLI 
public:
RasterImage LoadPsdChannel( 
   String^ fileName,
   int bitsPerPixel,
   CodecsLoadByteOrder order,
   int channelIndex,
   CodecsPsdChannelInfo^ channelInfo
) 

Parameters

fileName
A String containing the name of the image file to load.
bitsPerPixel

Resulting image pixel depth. Valid values are:

ValueMeaning
0Keep the original file's pixel depth (Do not convert).
1 to 8The specified bits per pixel in the resulting image.
1212 bits per pixel in the resulting image.
1616 bits per pixel in the resulting image.
2424 bits per pixel in the resulting image.
3232 bits per pixel in the resulting image.
4848 bits per pixel in the resulting image.
6464 bits per pixel in the resulting image.

order
The desired color order.
channelIndex
Index of the channel to load. This index is zero-based. Pass 0 to load the first channel, 1 to load the second channel, etc.
channelInfo
a CodecsPsdChannelInfo object to be updated with information about the loaded channel. Pass a null reference (Nothing in Visual Basic) for this parameter if channel information is not needed.

Return Value

The RasterImage object that this method loads.

Example

This example loads all channels from a PSD file

Visual BasicCopy Code
Public Sub LoadPsdChannels()
   RasterCodecs.Startup()
   Dim codecs As New RasterCodecs()

   Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Sunflower.psd"

   Dim imageInfo As CodecsImageInfo = codecs.GetInformation(srcFileName, False)
   For iCount As Integer = 0 To imageInfo.Psd.Channels - 1
      Dim ChannelInfo As New CodecsPsdChannelInfo()
      Dim ChannelImage As RasterImage = codecs.LoadPsdChannel(srcFileName, 0, CodecsLoadByteOrder.Rgb, iCount, ChannelInfo)

      Dim destFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Channel_"
      destFileName = destFileName & iCount & ".Bmp"

      codecs.Save(ChannelImage, destFileName, RasterImageFormat.Bmp, ChannelImage.BitsPerPixel)

      ChannelImage.Dispose()
   Next
   ' Clean up
   codecs.Dispose()
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void LoadPsdChannels() 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Sunflower.psd"; 
 
   CodecsImageInfo imageInfo = codecs.GetInformation(srcFileName, false); 
   for (int iCount = 0; iCount < imageInfo.Psd.Channels; iCount++) 
   { 
      CodecsPsdChannelInfo ChannelInfo = new CodecsPsdChannelInfo(); 
      RasterImage ChannelImage = codecs.LoadPsdChannel(srcFileName, 0, CodecsLoadByteOrder.Rgb, iCount, ChannelInfo); 
 
      string destFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Channel_"; 
      destFileName = destFileName + iCount + ".Bmp"; 
 
      codecs.Save(ChannelImage, destFileName, RasterImageFormat.Bmp, ChannelImage.BitsPerPixel); 
 
      ChannelImage.Dispose(); 
   } 
   // Clean up  
   codecs.Dispose(); 
   RasterCodecs.Shutdown();  
}

Remarks

Use this method to load PSD files only.

This method works similarly to a normal RasterCodecs.Load(String) method, except that it loads only a channel from a PSD file. It loads the channel specified in channel.

Before calling this method, you may need to get or set file information, such as the number of channels on the file. Refer to CodecsPsdImageInfo.

The number of channels in a file is indicated in CodecsPsdImageInfo.Channels. If this number is 0, the file does not contains any channels and this method should not be called.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also