Leadtools.Codecs Namespace > RasterCodecs Class : Transform Method |
Indicates the transform to be performed. Possible values are:
Value | Meaning |
---|---|
CodecsTransformFlags.Flip | Flip the image vertically |
CodecsTransformFlags.Reverse | Reverse the image (flip horizontally) |
CodecsTransformFlags.Rotate90 | Rotate the image clockwise by 90 degrees |
CodecsTransformFlags.Rotate180 | Rotate the image clockwise by 180 degrees |
CodecsTransformFlags.Rotate270 | Rotate the image clockwise by 270 degrees |
CodecsTransformFlags.None | Do nothing |
Optional callback method for processing custom markers. (This is useful for rotating JPEG files only). When transforming JPEG files, the method will enumerate all the markers contained in the file and it will pass them to this callback. The user has the ability to control the transformation for all the markers. For additional information on JPEG markers, please consult the JPEG specification.
public void Transform( string srcFileName, string destFileName, CodecsTransformFlags flags, int pageNumber, CodecsTransformMarkerCallback callback )
'Declaration Public Sub Transform( _ ByVal srcFileName As String, _ ByVal destFileName As String, _ ByVal flags As CodecsTransformFlags, _ ByVal pageNumber As Integer, _ ByVal callback As CodecsTransformMarkerCallback _ )
'Usage Dim instance As RasterCodecs Dim srcFileName As String Dim destFileName As String Dim flags As CodecsTransformFlags Dim pageNumber As Integer Dim callback As CodecsTransformMarkerCallback instance.Transform(srcFileName, destFileName, flags, pageNumber, callback)
public void Transform( string srcFileName, string destFileName, CodecsTransformFlags flags, int pageNumber, CodecsTransformMarkerCallback callback )
function Leadtools.Codecs.RasterCodecs.Transform( srcFileName , destFileName , flags , pageNumber , callback )
public: void Transform( String^ srcFileName, String^ destFileName, CodecsTransformFlags flags, int pageNumber, CodecsTransformMarkerCallback^ callback )
Indicates the transform to be performed. Possible values are:
Value | Meaning |
---|---|
CodecsTransformFlags.Flip | Flip the image vertically |
CodecsTransformFlags.Reverse | Reverse the image (flip horizontally) |
CodecsTransformFlags.Rotate90 | Rotate the image clockwise by 90 degrees |
CodecsTransformFlags.Rotate180 | Rotate the image clockwise by 180 degrees |
CodecsTransformFlags.Rotate270 | Rotate the image clockwise by 270 degrees |
CodecsTransformFlags.None | Do nothing |
Optional callback method for processing custom markers. (This is useful for rotating JPEG files only). When transforming JPEG files, the method will enumerate all the markers contained in the file and it will pass them to this callback. The user has the ability to control the transformation for all the markers. For additional information on JPEG markers, please consult the JPEG specification.
Currently, only JPEG, CMP and JPEG TIFF formats are supported.
Only one of the rotate flags can be specified.
The files transformed by this method will be read transformed by other applications capable of reading these file formats.
JPEG and Exif JPEG stamps are transformed according to the flags specified in flags. Please note that some JPEG stamps will not be transformed by this method. Specifically, stamps stored in markers other than APP0 and APP1 will not be transformed. Use the callback parameter to handle these cases. For example, if a stamp is in the APP14 marker, check for this in the callback and write your own stamp using SaveStamp(RasterImage,String).
For JPEG files, the size of the image might be changed. The image width and height is adjusted to be a multiple of 8 or 16 depending on the subsampling present in the image. If the image is 4:4:4, the width and height is adjusted to be a multiple of 16. If the image is 422, the original width is adjusted to be a multiple of 16 and the height to be a multiple of 8. After rotation, the width might become height. If the image is 411, the width and height are adjusted to be a multiple of 16.
The transformation is lossless. It is better than loading the image, transforming it using Leadtools.ImageProcessing.RotateCommand or Leadtools.ImageProcessing.FlipCommand and resaving it. Repeated load and save process will cause image degradation, but calling this method will not cause any image degradation.
The rotation transformations are performed before the flip/reverse operations.
Use the WriteTransformMarker(Int32,Byte[],Int32,Int32) method to control how the transform markers are used.
Public Sub TransformExample() Dim codecs As RasterCodecs = New RasterCodecs() Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp") Dim destFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1_Transform.cmp") codecs.Transform(srcFileName, destFileName, CodecsTransformFlags.Rotate90, 1, AddressOf MyCodecsTransformMarkerCallback) ' Clean up codecs.Dispose() End Sub Private Function MyCodecsTransformMarkerCallback(ByVal id As Integer, ByVal buffer As RasterNativeBuffer, ByVal transform As CodecsTransformFlags) As CodecsTransformMarkerAction Console.WriteLine("Transforming: id: {0}, Data Length: {1}, transform: {2}", id, buffer.Length, transform) Return CodecsTransformMarkerAction.Default End Function Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
public void TransformExample() { RasterCodecs codecs = new RasterCodecs(); string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); string destFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1_Transform.cmp"); codecs.Transform( srcFileName, destFileName, CodecsTransformFlags.Rotate90, 1, MyCodecsTransformMarkerCallback); // Clean up codecs.Dispose(); } CodecsTransformMarkerAction MyCodecsTransformMarkerCallback(int id, RasterNativeBuffer buffer, CodecsTransformFlags transform) { Console.WriteLine("Transforming: id: {0}, Data Length: {1}, transform: {2}", id, buffer.Length, transform); return CodecsTransformMarkerAction.Default; } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2