Gif Object
Overview
The Gif object creates, opens, resizes, manages and saves GIF images. This object was introduced in version 2.0 and is covered in detail in Chapter 9 - GIF Output.
Member List
Properties
Returns a binary array of bytes representing an 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 the inside areas of a bar, circle, ellipse, quadrilateral and pie, unless BrushSolid is set to False.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Specifies whether the brush for the current frame is solid or transparent. True (solid) by default.
See also: Section 9.2 - AspJpeg's GIF Output Support.
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.
See also: Section 9.2 - AspJpeg's GIF Output Support.
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'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 PrintTextEx 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. This property does not affect the PrintText method.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Specifies font family such as "Arial" or "Courier New". A system-default font is used if this property is not specified, or the specified font is not found. This property is to be used in conjunction with the PrintText method. It does not affect the PrintTextEx method.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Specifies text rotation angle (in degrees, rotation is counter-clockwise) for both the PrintText and PrintTextEx methods. 0 (horizontal) by default.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Specifies font size for both PrintText and PrintTextEx methods, in pixels. 24 by default.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Specifies line spacing adjustment (in pixels) for the PrintTextEx method. A positive value increases the default line spacing, a negative value decreases it.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Specifies the width of an area in which a text string drawn via PrintTextEx 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).
See also: Section 9.2 - AspJpeg's GIF Output Support.
Returns the total number of frames in the GIF image.
See also: Section 9.2 - AspJpeg's GIF Output Support.
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 Gif 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.
This parameterized property returns or 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 PaletteSize * 3 - 1. For example, PaletteItem(True, 4) refers to the Green component of the 2nd entry of the global palette.
See also: Section 9.5 - Palette Management.
This parameterized property returns or 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 pen color index for the current frame. This property affects all drawing methods and also PrintText and PrintTextEx.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Specifies a pen width for the current frame. This property affects all drawing methods.
See also: Section 9.2 - AspJpeg's GIF Output Support.
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.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Adds a new frame populated with Image which is an instance of the ASPJpeg 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 circular arc with a center in (X, Y) on the current frame. The arc radius is specified by Radius (in pixels). StartAngle specifies the angle (in degrees) of the arc's starting point, and ArcAngle specifies the arc's span, in the counterclockwise direction. Uses the current pen. Arcs are not filled.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Draws a rectangle specified by the coordinates of its upper-left and lower-right corners (in pixels) on the current frame using the current pen and brush.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Draws a circle specified by its center coordinates and radius (in pixels) on the current frame using the current pen and brush.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Draws an ellipse specified by the coordinates of its bounding rectangle (in pixels) on the current frame using the current pen and brush.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Draws a line specified by the coordinates of its starting and ending points (in pixels) on the current frame using the current pen.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Draws a pie-shaped wedge with a center in (X, Y) on the current frame. The radius is specified by Radius (in pixels). StartAngle specifies the angle (in degrees) of the arc's starting point, and EndAngle specifies the arc's ending point, in the counterclockwise direction. Uses the current pen and brush.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Draws a quadrilateral specified by the coordinates of its 4 corners on the current frame using the current pen and brush.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Draws a rectangle with rounded corners on the current frame using the current pen and brush. The rectangle is specified by the coordinates of its upper-left and lower-right corners (in pixels). The corners are rounded by an ellipse with the width and height specified by CornerWidth andCornerHeight.
See also: Section 9.2 - AspJpeg's GIF Output Support.
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.
Moves the frame specified by the first argument 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 file. Populates all the frames and assigns all the Gif object properties. Path must point to a GIF file, any other format will be rejected.
See also: 9.3 - GIF Image Resizing.
Same as Open but opens a GIF image from a binary source such as a recordset. Image must be a safe array of bytes containing a GIF image. All other formats will be rejected.
See also: 9.3 - GIF Image Resizing.
Same as Open but opens a GIF image from a binary source such as a recordset. Image must be a safe array of bytes containing a GIF image. All other formats will be rejected.
See also: 9.3 - GIF Image Resizing.
Prints anti-aliased text using a TrueType/OpenType or Type 1 font specified by its physical path. 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.
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.
See also: Section 9.2 - AspJpeg's GIF Output Support.
Resizes the current image while preserving its transparency and animation. If either NewWidth or NewHeight arguments are specified (but not both) the omitted argument is calculated automatically to preserve the original aspect ratio. 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 safe 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 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.