📄 gdk-gdkrgb.html
字号:
intmain (int argc, char *argv[]){ GtkWidget *window, *darea; gint x, y; guchar *pos; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); darea = gtk_drawing_area_new (); gtk_widget_set_size_request (darea, IMAGE_WIDTH, IMAGE_HEIGHT); gtk_container_add (GTK_CONTAINER (window), darea); gtk_signal_connect (GTK_OBJECT (darea), "expose-event", GTK_SIGNAL_FUNC (on_darea_expose), NULL); gtk_widget_show_all (window); /* Set up the RGB buffer. */ pos = rgbbuf; for (y = 0; y < IMAGE_HEIGHT; y++) { for (x = 0; x < IMAGE_WIDTH; x++) { *pos++ = x - x % 32; /* Red. */ *pos++ = (x / 32) * 4 + y - y % 32; /* Green. */ *pos++ = y - y % 32; /* Blue. */ } } gtk_main (); return 0;}gbooleanon_darea_expose (GtkWidget *widget, GdkEventExpose *event, gpointer user_data){ gdk_draw_rgb_image (widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, GDK_RGB_DITHER_MAX, rgbbuf, IMAGE_WIDTH * 3); return TRUE;}</pre></div></div><br class="example-break"></div><div class="refsect1" lang="en"><a name="id3126172"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3126182"></a><h3><a name="gdk-rgb-init"></a>gdk_rgb_init ()</h3><a class="indexterm" name="id3126196"></a><pre class="programlisting">void gdk_rgb_init (void);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">gdk_rgb_init</code> is deprecated and should not be used in newly-written code.</p></div><p>This function no longer does anything at all. It's completely useless(and harmless).</p></div><hr><div class="refsect2" lang="en"><a name="id3126232"></a><h3><a name="gdk-draw-rgb-image"></a>gdk_draw_rgb_image ()</h3><a class="indexterm" name="id3126245"></a><pre class="programlisting">void gdk_draw_rgb_image (<a class="link" href="gdk-Drawing-Primitives.html#GdkDrawable">GdkDrawable</a> *drawable, <a class="link" href="gdk-Graphics-Contexts.html#GdkGC">GdkGC</a> *gc, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> x, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> y, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> width, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> height, <a class="link" href="gdk-GdkRGB.html#GdkRgbDither">GdkRgbDither</a> dith, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar">guchar</a> *rgb_buf, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> rowstride);</pre><p>Draws an RGB image in the drawable. This is the core GdkRGBfunction, and likely the only one you will need to use.</p><p>The <em class="parameter"><code>rowstride</code></em> parameter allows for lines to be aligned more flexibly.For example, lines may be allocated to begin on 32-bit boundaries,even if the width of the rectangle is odd. Rowstride is also usefulwhen drawing a subrectangle of a larger image in memory. Finally, toreplicate the same line a number of times, the trick of setting<em class="parameter"><code>rowstride</code></em> to 0 is allowed.</p><p>In general, for 0 <= i < <em class="parameter"><code>width</code></em> and 0 <= j < height,the pixel (x + i, y + j) is colored with red value <em class="parameter"><code>rgb_buf</code></em>[<em class="parameter"><code>j</code></em> *<em class="parameter"><code>rowstride</code></em> + <em class="parameter"><code>i</code></em> * 3], green value <em class="parameter"><code>rgb_buf</code></em>[<em class="parameter"><code>j</code></em> * <em class="parameter"><code>rowstride</code></em> + <em class="parameter"><code>i</code></em> * 3 +1], and blue value <em class="parameter"><code>rgb_buf</code></em>[<em class="parameter"><code>j</code></em> * <em class="parameter"><code>rowstride</code></em> + <em class="parameter"><code>i</code></em> * 3 + 2].</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>drawable</code></em> :</span></p></td><td>The <a class="link" href="gdk-Drawing-Primitives.html#GdkDrawable"><span class="type">GdkDrawable</span></a> to draw in (usually a <a class="link" href="gdk-Windows.html#GdkWindow"><span class="type">GdkWindow</span></a>).</td></tr><tr><td><p><span class="term"><em class="parameter"><code>gc</code></em> :</span></p></td><td>The graphics context (all GDK drawing operations require one; itscontents are ignored).</td></tr><tr><td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td><td>The x coordinate of the top-left corner in the drawable.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>y</code></em> :</span></p></td><td>The y coordinate of the top-left corner in the drawable.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>width</code></em> :</span></p></td><td>The width of the rectangle to be drawn.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>height</code></em> :</span></p></td><td>The height of the rectangle to be drawn.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>dith</code></em> :</span></p></td><td>A <a class="link" href="gdk-GdkRGB.html#GdkRgbDither"><span class="type">GdkRgbDither</span></a> value, selecting the desired dither mode.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>rgb_buf</code></em> :</span></p></td><td>The pixel data, represented as packed 24-bit data.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>rowstride</code></em> :</span></p></td><td>The number of bytes from the start of one row in <em class="parameter"><code>rgb_buf</code></em> to thestart of the next.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3126605"></a><h3><a name="gdk-draw-rgb-image-dithalign"></a>gdk_draw_rgb_image_dithalign ()</h3><a class="indexterm" name="id3126619"></a><pre class="programlisting">void gdk_draw_rgb_image_dithalign (<a class="link" href="gdk-Drawing-Primitives.html#GdkDrawable">GdkDrawable</a> *drawable, <a class="link" href="gdk-Graphics-Contexts.html#GdkGC">GdkGC</a> *gc, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> x, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> y, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> width, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> height, <a class="link" href="gdk-GdkRGB.html#GdkRgbDither">GdkRgbDither</a> dith, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guchar">guchar</a> *rgb_buf, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> rowstride, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> xdith, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> ydith);</pre><p>Draws an RGB image in the drawable, with an adjustment for dither alignment.</p><p>This function is useful when drawing dithered images into a windowthat may be scrolled. Pixel (x, y) will be drawn dithered as if itsactual location is (x + <em class="parameter"><code>xdith</code></em>, y + <em class="parameter"><code>ydith</code></em>). Thus, if you draw animage into a window using zero dither alignment, then scroll up onepixel, subsequent draws to the window should have <em class="parameter"><code>ydith</code></em> = 1.</p><p>Setting the dither alignment correctly allows updating of small partsof the screen while avoiding visible "seams" between the differentdither textures.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>drawable</code></em> :</span></p></td><td>The <a class="link" href="gdk-Drawing-Primitives.html#GdkDrawable"><span class="type">GdkDrawable</span></a> to draw in (usually a <a class="link" href="gdk-Windows.html#GdkWindow"><span class="type">GdkWindow</span></a>).</td></tr><tr><td><p><span class="term"><em class="parameter"><code>gc</code></em> :</span></p></td><td>The graphics context.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td><td>The x coordinate of the top-left corner in the drawable.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>y</code></em> :</span></p></td><td>The y coordinate of the top-left corner in the drawable.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>width</code></em> :</span></p></td><td>The width of the rectangle to be drawn.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>height</code></em> :</span></p></td><td>The height of the rectangle to be drawn.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>dith</code></em> :</span></p></td><td>A <a class="link" href="gdk-GdkRGB.html#GdkRgbDither"><span class="type">GdkRgbDither</span></a> value, selecting the desired dither mode.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>rgb_buf</code></em> :</span></p></td><td>The pixel data, represented as packed 24-bit data.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>rowstride</code></em> :</span></p></td><td>The number of bytes from the start of one row in <em class="parameter"><code>rgb_buf</code></em> to thestart of the next.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>xdith</code></em> :</span></p></td><td>An x offset for dither alignment.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>ydith</code></em> :</span></p></td><td>A y offset for dither alignment.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3126951"></a><h3><a name="gdk-draw-indexed-image"></a>gdk_draw_indexed_image ()</h3><a class="indexterm" name="id3126964"></a><pre class="programlisting">void gdk_draw_indexed_image (<a class="link" href="gdk-Drawing-Primitives.html#GdkDrawable">GdkDrawable</a> *drawable, <a class="link" href="gdk-Graphics-Contexts.html#GdkGC">GdkGC</a> *gc, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> x, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> y, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> width, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> height,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -