1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>XmHTML Programmers Manual: XmHTMLImageDefaultProc</TITLE>
<META HTTP-EQUIV="Keywords" CONTENT="XmHTML, HTML, Motif, Widget, eXode, XntHelp, Linux">
<META HTTP-EQUIV="Reply-to" CONTENT="ripley@xs4all.nl">
<META HTTP-EQUIV="Description" CONTENT="XmHTMLImageDefaultProc - XmHTML default image loading function.">
<META NAME="Author" CONTENT="Koen D'Hondt">
<META NAME="Copyright" content="1995-1997 by Ripley Software Development">
<META NAME="Source" content="$Source$">
<META NAME="Revision" content="$Revision$">
<META NAME="Font" content="helvetica">
<link rev="made" href="mailto:ripley@xs4all.nl">
<link rel="home" href="index.html">
<link rel="previous" href="ImCreate.html">
<link rel="next" href="ImDestro.html">
<link rel="up" href="../man.html">
<link rel="copyright" href="copyrights.html">
</HEAD>
<BODY BGCOLOR="#FFFFFF" text="#000000">
<h3><font face="helvetica,arial">Name</font></h3>
<blockquote>
XmHTMLImageDefaultProc - XmHTML default image loading function
</blockquote>
<h3><font face="helvetica,arial">Synopsis</font></h3>
<blockquote>
XmImageInfo *XmHTMLImageDefaultProc(Widget w, String file,
unsigned char *buf, int size)
</blockquote>
<h3><font face="helvetica,arial">Description</font></h3>
<blockquote>
XmHTMLImageDefaultProc is the default image loading function of a XmHTML
widget. By default, this function is capable of decoding X11 bitmaps (xbm),
X11 pixmaps (xpm) and GIF87a and GIF89a images and animations.
<p>
Support for JPEG, PNG and GZF images is a compile time option and as such
may or may not be present in your version of the XmHTML library.
<p>
The value returned by this function is a structure containing all the
information a XmHTML widget requires to create the image and can be
used as the return value for the callback resource installed on the
XmNimageProc resource.
<p>
<dl>
<dt>w
<dd>Specifies the parent Widget ID. This must be a widget of class
xmHTMLWidgetClass;
<dt>file
<dd>if <i>size</i> is 0, the full path of the image to be decoded.
If <i>buf</i> and <i>size</i> are non-zero, the original url of
the image that is to be loaded. This argument may never be NULL.
<dt>buf
<dd>preloaded image data. The size of this data is given by the
<i>size</i> argument and is ignored if the <i>size</i> argument
is zero.
<dt>size
<dd>size of the preloaded image data. This argument is ignored if
<i>buf</i> is NULL.
</dl>
<p>
If size and/or buf is NULL, <i>file</i> must represent the full
location of the image that is to be decoded. If this file can not
be found or accessed
<p>
To fully appreciate this function, one is advised to read the
XmImageInfo(3X) manual page.
</blockquote>
<h3><font face="helvetica,arial">Return Value</font></h3>
<blockquote>
A newly allocated XmImageInfo structure or NULL upon failure.
<p>
Common causes for failure are:
<p>
<ul>
<li>the image to be decoded is of an unsupported type;
<li>the <i>file</i> argument is NULL;
<li>the <i>file</i> argument represents a file that could not be
found or accessed.
</ul>
</blockquote>
<h3><font face="helvetica,arial">Examples</font></h3>
<blockquote>
The simplest example of a function installed for the XmNimageProc resource
is the following:
<pre>
XmImageInfo*
loadImage(Widget w, String url, Dimension width, Dimension height,
XtPointer client_data)
{
return(XmHTMLImageDefaultProc(w, url, NULL, 0));
}
</pre>
A more advanced example is:
<pre>
XmImageInfo*
loadImage(Widget w, String url, Dimension width, Dimension height,
XtPointer client_data)
{
XmImageInfo *image_info;
unsigned char image_type = IMAGE_UNKNOWN;
/* check if this is a local url */
if((XmHTMLGetURLType(url)) != ANCHOR_FILE_LOCAL)
return(NULL);
/* it is a local file. Check if it is of a supported type */
image_type = XmHTMLImageGetType(url, NULL, 0);
if(image_type == IMAGE_ERROR || image_type == IMAGE_UNKNOWN)
{
/* an error occured or the type of this image is unsupported */
return(NULL);
}
/* Load it using the default function */
if((image_info = XmHTMLImageDefaultProc(w, url, NULL, 0)) != NULL)
{
/*
* Prevent a XmHTML widget from freeing this image immediatly.
* Also prevent scaling of the image (scaling images is
* actually a violation of the HTML standard!).
*/
image_info->options &= ~XmIMAGE_DEFERRED_FREE & ~XmIMAGE_ALLOW_SCALE;
return(image_info);
}
return(NULL);
}
</pre>
A more advanced version of this function could fetch remote images,
check if support for JPEG and PNG images is available before calling
XmHTMLImageDefaultProc, use delayed image loading, implement a caching
scheme for the returned XmImageInfo structure or add a decoder for image
types unsupported by XmHTMLImageDefaultProc (this can include other types
of animations as well!).
</blockquote>
<h3><font face="helvetica,arial">See Also</font></h3>
<blockquote>
XmHTML(3X), XmImageInfo(3X), XmImageCreate(3X), XmImageCreateFromInfo(3X),
XmImageDestroy(3X), XmImage(3X)
</blockquote>
<hr noshade size="2" width="25%">
<i><font size="-1">
XmHTML, June 4, 1998
</font></i>
</body>
</html>
|