JpegGif Object
Overview
The JpegGif object creates, opens, resizes, manages and saves GIF images. This object is covered in detail in Chapter 9 - GIF Output.
Member List
Properties
Returns a binary array of bytes representing the output GIF image. This property is useful for saving images in the database as BLOBs.
See also: Chapter 9 - GIF Output.
Specifies a brush color index for the current frame. Affects all the fill operations.
Returns or specifies the current frame within a GIF image. All drawing operations are always performed on the current frame. The frame index is 1-based and must be between 1 and FrameCount.
Returns or specifies the delay (in 100ths of a second) of the current frame in an animated GIF. 100 (1 second) by default.
See also: Section 9.2 - AspJpeg.NET's GIF Output Support, Section 9.7.2 - Other Animation Management Properties.
Controls the way frames in an animated GIF replace each other. Valid values are:
- Leave the current image in place and draw the next image on top of it. This is the default method.
- The canvas should be restored to the background color before the next image is rendered.
- The canvas should be restored to its previous state before the current image is drawn.
See also: Section 9.4 - Using External Images as Frames, Section 9.7.2 - Other Animation Management Properties.
Specifies text alignment for the PrintText method. Valid values are: 0 - left (default), 1 - right, 2 - center and 3 - justified. If a value other than 0 is specified, the FontWidth property must also be specified.
Specifies text rotation angle (in degrees, rotation is counter-clockwise) for the PrintText method. 0 (horizontal) by default.
Specifies font size for the PrintText method, in pixels. 12 by default.
Specifies line spacing adjustment (in pixels) for the PrintText method. A positive value increases the default line spacing, a negative value decreases it.
Specifies the width of an area in which a text string drawn via PrintText is to be inscribed. Activates word wrapping if necessary. This property must also be set if the FontAlign property is set to a value other than 0 (left alignment).
Returns the total number of frames in the GIF image.
Returns or specifies the height of the current frame in pixels.
Returns or specifies the horizontal offset of the current frame in pixels.
Returns or specifies the vertical offset of the current frame in pixels.
0 by default. If set to a valid 1-based frame index, instructs the JpegGif object to only save the specified frame when a Save method is called. This property is mostly useful for debugging only.
See also: Section 9.7.3 - Saving Individual Frames.
Returns or specifies the width of the current frame in pixels.
Returns or specifies the overall height of a GIF image in pixels. This property does not affect the size of individual frames within the image. If an image has no frames yet, callings AddFrame or AddImage for the first time sets the Height to that of the frame being added.
Returns or specifies the number of times an animated GIF runs its sequence before stopping. 0 by default which means the sequence runs indefinitely.
See also: Section 9.7.2 - Other Animation Management Properties.
Specifies a pen color index for the current frame. This property affects all drawing methods and also PrintText.
Specifies a pen width for the current frame. This property affects all drawing methods.
This parameterized property returns or sets the color index for a pixel specified by [Col, Row] within the current frame.
Controls the quality of true-color to 256-color conversion when AddImage is called. Valid values are from 1 to 30, 1 being the highest quality but also the slowest speed. The default value is 20 which provides an adequate balance between speed and quality. Setting this property to anything below 10 is not recommended for performance considerations.
Returns or specifies the transparent color index for the current frame. Setting this property has a side effect of setting the TranspColorSet property to true.
See also: Section 9.6 - Transparency
Returns true if the current frame has a transparent color index associated with it. The index itself is returned via the TranspColor property. Setting this property to false effectively removes a transparent color from the current frame.
See also: Section 9.6 - Transparency.
Returns or specifies the overall width of a GIF image in pixels. This property does not affect the size of individual frames within the image. If an image has no frames yet, callings AddFrame or AddImage for the first time sets the Width to that of the frame being added.
Methods
Adds an empty frame to the image with the specified width, height, and offsets. The newly added frame becomes the current one and is filled with color index 0. It has no local palette. The new frame is added to the end of the animation sequence.
If this is the first frame in the image, the overall image width and height are assigned the values from the new frame.
Adds a new frame populated with Image which is an instance of the JpegImage object. This method performs a true-color to 256-color conversion. The speed and quality of the conversion is determined by the Quantization property.
The new frame is assigned a 256-color local palette computed from the image being converted for optimal quality.
Removes all frames from the image. An empty image cannot be drawn on, resized, or saved.
Draws an arc with the center in (x, y), horizontal radius Radius1, vertical radius Radius2, beginning at the angle Angle1 relative to the horizontal axis of the ellipse, ending at the angle Angle2. The ellipse itself is tilted by an angle specified by TiltAngle. Uses the current pen's width, color, opacity and dash pattern, on the current frame.
Draws an ellipse with the center in (x, y) and horizontal and vertical radii Radius1 and Radius2, respectively, using the current pen's width, color, opacity and dash pattern, on the current frame.
Draws a line specified by the coordinates of its starting and ending points (in pixels) using the current pen's width, color, opacity and dash pattern, on the current frame.
Draws a rectangle with the upper-left corner in (x, y) and specified Width and Height using the current pen's width, color, opacity, dash pattern and other parameters, on the current frame.
Draws a rectangle with rounded corners on the current frame using the current pen's width, color, opacity and dash pattern. The rectangle is specified by the coordinates of its upper-left corner, width and height. The corners are rounded by an ellipse with the width and height specified by Rx and Ry.
Draws the segment of an ellipse with the center in (x, y), horizontal radius Radius1, vertical radius Radius2, beginning at the angle Angle1 relative to the horizontal axis of the ellipse, ending at the angle Angle2. The ellipse itself is tilted by an angle specified by TiltAngle. The segment is drawn on the current frame using the current pen's width, color, opacity, dash pattern and other parameters.
Fills an arc with the center in (x, y), horizontal radius Radius1, vertical radius Radius2, beginning at the angle Angle1 relative to the horizontal axis of the ellipse, ending at the angle Angle2. The ellipse itself is tilted by an angle specified by TiltAngle. The arc is filled on the current frame using the current brush's color and opacity.
Fills an ellipse with the center in (x, y) and horizontal and vertical radii Radius1 and Radius2, respectively. The ellipse is filled on the current frame using the current brush's color and opacity.
Fills a rectangle with the upper-left corner in (x, y) and specified Width and Height. The rectangle is filled on the current frame using the current brush's color and opacity.
Fills a rectangle with rounded corners on the current frame using the current brush's color and opacity. The rectangle is specified by the coordinates of its upper-left corner, width and height. The corners are rounded by an ellipse with the width and height specified by Rx and Ry.
Fill the segment of an ellipse with the center in (x, y), horizontal radius Radius1, vertical radius Radius2, beginning at the angle Angle1 relative to the horizontal axis of the ellipse, ending at the angle Angle2. The ellipse itself is tilted by an angle specified by TiltAngle. The segment is filled on the current frame using the current brush's color and opacity.
Scans the specified palette and looks for a color closest to the RGB values specified, and returns its index. If Global is true, the global palette is scanned, otherwise the local palette pertaining to the current frame is scanned.
See also: 9.7.4 - Finding a Closest Color.
Returns an RGB component of a palette item pointed to by Index in a palette specified by Global. If Global is true, the global palette is used, otherwise the local palette pertaining to the current frame is used. Index must be an integer between 0 and GetPaletteSize() * 3 - 1. For example, GetPaletteItem(true, 4) refers to the Green component of the 2nd entry of the global palette.
See also: 9.7.4 - Finding a Closest Color.
Returns the number of entries in a palette. If Global is true, the global palette is used, otherwise the local palette pertaining to the current frame is used.
See also: 9.7.4 - Finding a Closest Color.
Moves the frame specified by the first argument (1-based) to a new location specified by the 2nd argument. If the current frame is affected by the move, the CurrentFrame property will change to reflect the new position of the current frame.
See also: 9.7.1 - Other Frame Management Methods.
Opens a GIF image from a disk file specified by Path or a byte array specified by FileBytes. Populates all the frames and assigns all the JpegGif object properties. Path must point to a GIF file, any other format will be rejected.
See also: 9.3 - GIF Image Resizing.
Prints text using a TrueType/OpenType or Type 1 font specified by its physical path or byte array. Supports word wrapping, rotation, text alignment (to the left, right, center and justified) and adjustable line spacing.
Text - specifies the text string to be printed (in Unicode format). May contain CR/LF characters for multi-line display.
x, y - coordinates of the lower-left corner of the first character of the first line, relative to the upper-left corner of the image.
FontPath - specifies a physical path to the font file. The font does not need to be properly registered on the system as long as the path to the font file is known.
FontBytes - specifies a byte array containing the font. The font does not need to be properly registered on the system as long as the path to the font file is known.
FontIndex specifies a font index within a multi-font file (or byte array) and is 0 by default.
Additional optional parameters are specified via the following properties:
PenColor - specifies the text color index.
FontRotation - specifies the rotation angle around the (X, Y) point in degrees. A positive value creates a counter-clockwise rotation.
FontSize - specifies font size in pixels.
FontSpacing - specifies an adjustment in pixels for the default line spacing when multi-line text is being rendered. A positive value increases the line spacing, a negative one decreases it.
FontWidth - specifies the width of an area in which the text string is to be inscribed.
Word wrapping occurs if the text string does not fit in the area. This property must also be set if non-default text alignment is specified via FontAlign.
FontAlign - specifies text alignment. Valid values are: 0 - left (default), 1 - right, 2 - center, and 3 - justified. For values other than 0, FontWidth must also be specified.
Returns the width (in pixels) of the text string being drawn. If the string is split into multiple lines, returns the width of the longest line.
Removes the frame specified by its index. If the current frame is being removed, another frame becomes current, and the CurrentFrame property may change.
Resizes the current image while preserving its transparency and animation. If either NewWidth or NewHeight is zero, this argument is calculated automatically to preserve the original aspect ratio. NewWidth and NewHeight cannot both be zero. Interpolation is 0 (nearest-neighbor algorithm) by default. Using other algorithms may cause undesired artifacts when resizing certain animated images.
See also: Section 9.3 - GIF Image Resizing.
Saves the resultant GIF image to disk. If a file specified by Path already exists, it will be overwritten.
See also: Chapter 9 - GIF Output.
Same as Save but generates a unique filename if the file specified by Path already exists. A unique name is generated to avoid overwriting an existing file by appending a number in parentheses after the filename, such as image(1).jpg, image(2).jpg, etc. Returns the filename (without the path) under which the image ends up being saved.
See also: Chapter 9 - GIF Output.
Sends the resultant image directly to the client browser by internally calling Response.BinaryWrite. Automatically sets the Content-Type header to "image/gif".
If ContentDisposition is set, also sets the "Content-Disposition" header to a value specified by this argument. A typical value for this argument is
"filename=image_name.gif"or
"attachment;filename=image_name.gif"You can only use this method in an IIS environment.
See also: Chapter 9 - GIF Output.
Specifies a new palette by supplying an array of RGB values for all entries at once.
If Global is set to true, the global palette is changed, otherwise the local palette pertaining to the current frame is changed.
Palette is a byte array of numbers that are treated as consecutive RGB values of all palette entries. The size of the array must be 3 multiplied by a valid GIF palette size (2, 4, 8, ..., 256 entries.)
See also: 9.5 - Palette Management.
Specifies an RGB component of a palette item pointed to by Index in a palette specified by Global. If Global is true, the global palette is used, otherwise the local palette pertaining to the current frame is used. Index must be an integer between 0 and GetPaletteSize() * 3 - 1. For example, SetPaletteItem(true, 4, 255) sets the Green component of the 2nd entry of the global palette to 255.
See also: Section 9.5 - Palette Management.
Specifies the number of entries in a palette. If Global is true, the global palette is used, otherwise the local palette pertaining to the current frame is used. Setting a palette size to 0 effectively removes the palette.
See also: Section 9.5 - Palette Management.
Specifies a built-in (or "stock") palette by number.
If Global is set to true, the global palette is changed, otherwise the local palette pertaining to the current frame is changed.
Type selects one of the available stock palettes. The valid values are:
- 216 web-safe colors.
- 16 standard HTML colors.
- 256 grayscale colors.
See also: 9.5.3 - Stock Palettes.