Hi Taekyun,<div><br></div><div>Thank you for your response. I actually was copying the width and height from my memory and forgot to include the (double) cast. It doesn't make a difference in practice. Even trying a hard-coded 0.75 to presumably get a 75% image does not work.</div>
<div><br></div><div>I'm actually now having cairo paint the scaled image into a Pixmap instead of directly onto the window, so I can inspect the pixels. They seem to be zero.</div><div><br></div><div>I wonder if it's a depth issue. As I said, the source is an 8 bit grayscale image but the screen is 24 or 32 bits. I'm not sure if cairo can handle paining from one depth to another.<br>
<br><br><div class="gmail_quote">On Mon, Jun 27, 2011 at 10:43 AM, Taekyun Kim <span dir="ltr"><<a href="mailto:podain77@gmail.com">podain77@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div bgcolor="#FFFFFF"><div>I think you did integer division. Something like "(double)width / (double)xImage->width" might solve your problem.</div><div><br>2011. 6. 28. ¿ÀÀü 12:05 Justin Anderson <<a href="mailto:justin@rayonix.com" target="_blank">justin@rayonix.com</a>> ÀÛ¼º:<br>
<br></div><div><div></div><div class="h5"><div></div><blockquote type="cite"><div>I should mention that the source image is an 8 bit grayscale. Thanks.<br>
<br><br><div class="gmail_quote">On Mon, Jun 27, 2011 at 10:00 AM, Justin Anderson <span dir="ltr"><<a href="mailto:justin@rayonix.com" target="_blank"></a><a href="mailto:justin@rayonix.com" target="_blank">justin@rayonix.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<div><br></div><div>I'm trying to resize an X11 XImage which is a 640x480 pixel image from a video grabber, to be displayed on a window in an X11/Motif application.
</div><div><br></div><div>If I comment out the scale command in the following code, the image is displayed fine, albeit clipped on my window. If I uncomment the scale operation, there is no image in the window.</div><div>
<br></div><div>Any ideas? Thanks!</div><div><br></div><div><br></div><div><div><br></div><div> //Create a simple X11 window for displaying the XImage...</div><div> window = XCreateSimpleWindow(</div><div> display,</div>
<div> RootWindowOfScreen(screen),</div><div> 0, // x</div><div> 0, // y</div><div> width,</div><div> height,</div><div> 0, // border width</div><div> BlackPixelOfScreen(screen), // border</div>
<div> BlackPixelOfScreen(screen) // background</div><div> );</div><div> XMapRaised(display, window);</div><div> </div><div> //cairo stuff...</div><div> cairo_surface_t *surface_dest = cairo_xlib_surface_create(display, window, XDefaultVisualOfScreen(screen), width, height);</div>
<div> cairo_t *cr_dest = cairo_create(surface_dest);</div><div> </div><div> cairo_surface_t *surface_source = cairo_image_surface_create_for_data((unsigned char*)(xImage->data), CAIRO_FORMAT_RGB24, xImage->width, xImage->height, xImage->bytes_per_line);</div>
<div><span style="white-space:pre-wrap">        </span> </div><div> cairo_scale(cr_dest, width / xImage->width, height / xImage->height);</div><div><br></div><div> cairo_set_source_surface(cr_dest, surface_source, 0, 0);</div>
<div> cairo_paint(cr_dest);</div><div> cairo_surface_destroy(surface_source);</div><div><br></div><div> //Put the scaled XImage on the window...</div><div> XPutImage(display, window, gc, xImage, 0, 0, 0, 0, width, height);</div>
<div><span style="white-space:pre-wrap">        </span></div><div> cairo_surface_destroy(surface_dest);</div></div><div> cairo_surface_destroy(surface_source);</div>
</blockquote></div><br>
</div></blockquote></div></div><blockquote type="cite"><div><span>--</span><br><span>cairo mailing list</span><br><span><a href="mailto:cairo@cairographics.org" target="_blank">cairo@cairographics.org</a></span><br><span><a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a></span></div>
</blockquote></div></blockquote></div><br></div>