November 3, 2003

Interview with Ingo Rammer

ngo is an independent consultant, developer, author, and trainer based in Vienna, Austria. His books “Advanced .NET Remoting” and “Advanced .NET Remoting in VB.NET” were published by Apress in 2002. In his day-to-day work, he focuses mainly on the architecture of .NET applications, and works with several companies in the

Animation – A class to extract all the frames of an animated image

‘ This class loads an animated image and gives access to all its internal ‘ frames as Bitmap objects” Example:’ ‘ load the animation and extract its frames’ Me.Cursor = Cursors.WaitCursor’ Dim anim As New Animation(“D:SampleAnimation.gif”)’ Me.Cursor = Cursors.Default’ ‘ get a reference to the first and last frame’ Dim

GetGreyScaleImage – Convert a bitmap to greyscale

‘ Convert a bitmap to greyscale – the function returns a new bitmap,’ it does not directly modify the input image.’ Note: requires the GetGreyScale function” Example:’ Dim bmp As New Bitmap(“D:sample.gif”)’ PictureBox1.Image = GetGreyScaleImage(bmp)Function GetGreyScaleImage(ByRef bmp As Bitmap) As Bitmap ‘ create a new empty bitmap with the same

GetAnimationFrameCount – Retrieve the number of frames contained in the specified image

‘ Retrieve the number of frames contained in the specified image. For non-‘ animated images the function returns 1” Example:’ Dim frameCount As Integer = GetAnimationFrameCount(“D:sample.gif”)Function GetAnimationFrameCount(ByVal imgPath As String) As Integer ‘ load the image Dim img As System.Drawing.Image = System.Drawing.Image.FromFile(imgPath) Dim fdl As New Drawing.Imaging.FrameDimension(img.FrameDimensionsList(0)) ‘ get the

GetGreyScale – Convert a color to greyscale

‘ Convert a color to greyscale’ Example: Me.BackColor = GetGreyScale(Color.Red)Function GetGreyScale(ByVal col As Color) As Color Dim greyValue As Integer = CType(col.R * 0.3 + col.G * 0.59 + col.B * 0.11, _ Integer) Return Color.FromArgb(greyValue, greyValue, greyValue)End Function

GetImageFormat – Retrieve the format of the input image, according on its extension

‘ Return the format of the input image, according on its extension’ Example: Dim imgFormat As System.Drawing.imaging.ImageFormat = GetImageFormat’ (“D:sample.gif”)Function GetImageFormat(ByVal imgPath As String) As _ System.Drawing.imaging.ImageFormat imgPath = imgPath.ToLower() If imgPath.EndsWith(“.bmp”) Then Return System.Drawing.Imaging.ImageFormat.Bmp ElseIf imgPath.EndsWith(“.emf”) Then Return System.Drawing.Imaging.ImageFormat.Emf ElseIf imgPath.EndsWith(“.gif”) Then Return System.Drawing.Imaging.ImageFormat.Gif ElseIf imgPath.EndsWith(“.ico”) Then Return System.Drawing.Imaging.ImageFormat.Icon

ResizeImage – Resize an image, and optionally keep the original ratio automatically

‘ Resize the specified image file – The new dimensions are expressed in ‘ percentage of the original size.’ The resized image overwrites the original file.’ Note: requires the GetImageFormat function” Example:’ ResizeImage(“D:sample.gif”, 50.0, 50.0) ‘ make the image half the ‘ original size’ ResizeImage(“D:sample.gif”, 200.0, 300.0) ‘ double the