int DumpX(bufferdevice * dev, palette * pal) { Display * display; XImage * ximage; Window window; XEvent an_event; GC gc; Visual * visual; XGCValues values; int m, n, screen, dplanes; int width, height, ret = 1; ColorValues * cor; width = dev->MaxX; height = dev->MaxY; if ((display = XOpenDisplay(NULL)) == NULL) ret = 0; else { screen = DefaultScreen(display); dplanes = DisplayPlanes(display,screen); visual = XDefaultVisual(display,screen); if (!(window=XCreateSimpleWindow(display,RootWindow(display,screen),0,0,width,height,1,BlackPixel(display,screen),WhitePixel(display,screen)))) ret = 0; else { XSelectInput(display, window, EventMask); gc = XCreateGC(display, window, 0, &values); XMapWindow(display,window); XSync(display,False); ximage = XCreateImage(display,visual,dplanes,ZPixmap,0,malloc(width*height*sizeof(int)),width,height,8,0); for(m=0;m<height;m++) { for(n=0;n<width;n++) { cor = GetColor(dev->buffer[m*width+n],pal); ximage -> data[(m*4)*width+n*4] = (char) round((cor->blue)*255); ximage -> data[(m*4)*width+n*4+1] = (char) round((cor->green)*255); ximage -> data[(m*4)*width+n*4+2] = (char) round((cor->red)*255); ximage -> data[(m*4)*width+n*4+3] = (char) 0; } } XPutImage(display,window,gc,ximage,0,0,0,0,width,height); sleep(30); } } return ret; }
void MpImageWindow::MapXImage (void) // virtual { // draw the XImage to the window (if there is one) if (theXImage) { int f = GetFrameTotalWidth(), w = MpMin( Width()-2*f,image->GetWidth() ), h = MpMin( Height()-2*f,image->GetLength() ); XPutImage(Mp.theDisplay,Win(),Mp.theDrawGC,theXImage, 0,0, // offset in source image f,f, // offset in destination w,h); // effective size to draw } }
static void vo_x11_display (AVPicture * pic) { vo_lock (); vo_x11_vfmt2rgb (my_pic, pic); Ximg->data = my_pic->data[0]; XPutImage (Xdisplay, Xvowin, Xvogc, Ximg, 0, 0, 0, 0, dw, dh); if (vo_draw_string) x11_draw_string (&osd); XFlush (Xdisplay); vo_unlock (); }
void QXlibWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoint &offset) { Q_UNUSED(widget); Q_UNUSED(region); Q_UNUSED(offset); if (!painted) return; QXlibScreen *screen = QXlibScreen::testLiteScreenForWidget(widget); GC gc = xw->graphicsContext(); Window window = xw->xWindow(); #ifdef DONT_USE_MIT_SHM // just convert the image every time... if (!shm_img.isNull()) { QXlibWindow *win = static_cast<QXlibWindow*>(window()->platformWindow()); QImage image = shm_img; //img.convertToFormat( XImage *xi = XCreateImage(screen->display(), win->visual(), win->depth(), ZPixmap, 0, (char *) image.scanLine(0), image.width(), image.height(), 32, image.bytesPerLine()); int x = 0; int y = 0; /*int r =*/ XPutImage(screen->display(), window, gc, xi, 0, 0, x, y, image.width(), image.height()); xi->data = 0; // QImage owns these bits XDestroyImage(xi); } #else // Use MIT_SHM if (image_info && image_info->image) { //qDebug() << "Here we go" << image_info->image->width << image_info->image->height; int x = 0; int y = 0; // We could set send_event to true, and then use the ShmCompletion to synchronize, // but let's do like Qt/11 and just use XSync XShmPutImage (screen->display()->nativeDisplay(), window, gc, image_info->image, 0, 0, x, y, image_info->image->width, image_info->image->height, /*send_event*/ False); screen->display()->sync(); } #endif }
static void roll_up (vbi_page * pg, int first_row, int last_row) { ushort scol, *canvas = ximgdata + 45 * DISP_WIDTH; vbi_rgba col; int i, j; #if 1 /* soft */ sh_first = first_row; sh_last = last_row; shift = 26; bump(step, FALSE); canvas += 48 + (((last_row * CELL_HEIGHT) + CELL_HEIGHT - step) * DISP_WIDTH); col = pg->color_map[pg->text[last_row * pg->columns].background]; scol = RGB565 (col); for (j = 0; j < step; ++j) { if (pg->text[last_row * pg->columns].opacity == VBI_TRANSPARENT_SPACE) { for (i = 0; i < CELL_WIDTH * pg->columns; ++i) canvas[i] = RGB565 (COLORKEY); } else { for (i = 0; i < CELL_WIDTH * pg->columns; ++i) canvas[i] = scol; } canvas += DISP_WIDTH; } #else /* at once */ memmove (canvas + first_row * CELL_HEIGHT * DISP_WIDTH, canvas + (first_row + 1) * CELL_HEIGHT * DISP_WIDTH, (last_row - first_row) * CELL_HEIGHT * DISP_WIDTH * 2); draw_video (48, 45 + last_row * CELL_HEIGHT, DISP_WIDTH - 48, CELL_HEIGHT); #endif XPutImage (display, window, gc, ximage, 0, 0, 0, 0, DISP_WIDTH, DISP_HEIGHT); }
/*********************************************************************** * BRUSH_DitherColor */ static Pixmap BRUSH_DitherColor( COLORREF color, int depth) { /* X image for building dithered pixmap */ static XImage *ditherImage = NULL; static COLORREF prevColor = 0xffffffff; unsigned int x, y; Pixmap pixmap; GC gc = get_bitmap_gc(depth); if (!ditherImage) { ditherImage = X11DRV_DIB_CreateXImage( MATRIX_SIZE, MATRIX_SIZE, depth ); if (!ditherImage) { ERR("Could not create dither image\n"); return 0; } } wine_tsx11_lock(); if (color != prevColor) { int r = GetRValue( color ) * DITHER_LEVELS; int g = GetGValue( color ) * DITHER_LEVELS; int b = GetBValue( color ) * DITHER_LEVELS; const int *pmatrix = dither_matrix; for (y = 0; y < MATRIX_SIZE; y++) { for (x = 0; x < MATRIX_SIZE; x++) { int d = *pmatrix++ * 256; int dr = ((r + d) / MATRIX_SIZE_2) / 256; int dg = ((g + d) / MATRIX_SIZE_2) / 256; int db = ((b + d) / MATRIX_SIZE_2) / 256; XPutPixel( ditherImage, x, y, PIXEL_VALUE(dr,dg,db) ); } } prevColor = color; } pixmap = XCreatePixmap( gdi_display, root_window, MATRIX_SIZE, MATRIX_SIZE, depth ); XPutImage( gdi_display, pixmap, gc, ditherImage, 0, 0, 0, 0, MATRIX_SIZE, MATRIX_SIZE ); wine_tsx11_unlock(); return pixmap; }
/*************************************************************************** Converts an image to a pixmap... ***************************************************************************/ static Pixmap image2pixmap(XImage *xi) { Pixmap ret; XGCValues values; GC gc; ret = XCreatePixmap(display, root_window, xi->width, xi->height, xi->depth); values.foreground = 1; values.background = 0; gc = XCreateGC(display, ret, GCForeground | GCBackground, &values); XPutImage(display, ret, gc, xi, 0, 0, 0, 0, xi->width, xi->height); XFreeGC(display, gc); return ret; }
void Draw(Image imagem, int positionX,int positionY){ int m,n; for(m=positionY;m<imagem.sizeY+positionY;m++) { for(n=positionX;n<imagem.sizeX+positionX;n++) { int x = n-positionX; int y = m-positionY; if(imagem.pixel[x][y].printable){ WindowProperties.ximage -> data[(m*4)*WindowProperties.width+n*4] = (char)(int)(imagem.pixel[x][y].color.blue); WindowProperties.ximage -> data[(m*4)*WindowProperties.width+n*4+1] = (char)(int)(imagem.pixel[x][y].color.green); WindowProperties.ximage -> data[(m*4)*WindowProperties.width+n*4+2] = (char)(int)(imagem.pixel[x][y].color.red); WindowProperties.ximage -> data[(m*4)*WindowProperties.width+n*4+3] = (char) 0; } } } XPutImage(WindowProperties.display,WindowProperties.window,WindowProperties.gc,WindowProperties.ximage,0,0,0,0,WindowProperties.width,WindowProperties.height); }
int camera_shoot(struct IplImage *img, XImage *ximg, GC theGC, Window theWindow, int x1, int y1) { int x, y; for (y = 0; y < img->height; y++) for (x = 0; x < img->width; x++) { unsigned char r, g, b; r = img->data[img->nchans * (y * img->width + x) + 0]; g = img->data[img->nchans * (y * img->width + x) + 1]; b = img->data[img->nchans * (y * img->width + x) + 2]; XPutPixel(ximg, x, y, ((r << 16) | (g << 8) | b)); } XPutImage(theDisplay, theWindow, theGC, ximg, 0, 0, x1, y1, 640, 480); return 0; }
int TkPutImage( unsigned long *colors, /* Array of pixel values used by this image. * May be NULL. */ int ncolors, /* Number of colors used, or 0. */ Display *display, Drawable d, /* Destination drawable. */ GC gc, XImage *image, /* Source image. */ int src_x, int src_y, /* Offset of subimage. */ int dest_x, int dest_y, /* Position of subimage origin in drawable. */ unsigned int width, unsigned int height) /* Dimensions of subimage. */ { return XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height); }
void DrawImage(Display * dpy, Window win, XImage * image) { static GC gc; if(win!=0) { if(gc==0) { XGCValues gc_val; gc = XCreateGC (dpy, win, GCForeground|GCBackground, &gc_val); } /*for(i=0;i<100;i++) { image->data*/ XPutImage (dpy, win, gc, image, 0, 0, 0, 0, 1024, 768); } }
void Xvars::put_image(int dpyNum,Drawable dest,XImage* src,const Size& size) { // Create temp GC to set foreground and background in case we are // dealing with a mask. GC gc; XGCValues values; values.foreground = 1; values.background = 0; gc = XCreateGC(dpy[dpyNum],dest, GCForeground | GCBackground,&values); XPutImage(dpy[dpyNum],dest,gc,src, 0,0,0,0,size.width,size.height); // Kill temp GC. XFreeGC(dpy[dpyNum],gc); }
void up_x11update(void) { #ifndef CONFIG_SIM_X11NOSHM if (b_useshm) { XShmPutImage(g_display, g_window, g_gc, g_image, 0, 0, 0, 0, g_fbpixelwidth, g_fbpixelheight, 0); } else #endif { XPutImage(g_display, g_window, g_gc, g_image, 0, 0, 0, 0, g_fbpixelwidth, g_fbpixelheight); } XSync(g_display, 0); }
void display_image (int xsize, int ysize, Pixel *R, Pixel *G, Pixel *B) { static char data[(int) (MAXCOLS * MAXROWS)]; int i; static XImage *ximage; static int frame_count=-1; frame_count++; if ((frame_count % (NSAMPLESECS * MAXFPS)) == 0) { gettimeofday(&tp2, NULL); time_elapsed = (int) (((tp2.tv_sec - tp1.tv_sec) * 1000) + ((tp2.tv_usec - tp1.tv_usec) / 1000)); printf ("caught %d frames in %.1f sec\n", (frame_count) / NSAMPLESECS, ((float) time_elapsed) / (NSAMPLESECS * 1000.0)); tp1 = tp2; frame_count = 0; translate_setup (xsize, ysize, R, G, B); redo_cmap(rmap,gmap,bmap); return; } translate_box (R, G, B, xsize, ysize, data); for (i = 0; i < xsize * ysize; i++) data[i] = pixels[data[i]]; ximage = XCreateImage(display_, DefaultVisual(display_, DefaultScreen(display_)), 8, ZPixmap, 0, (char*) data, MAXCOLS, MAXROWS, 8, MAXCOLS); ximage->byte_order = XImageByteOrder(display_); XPutImage(display_, wtwin_, gc_, ximage, 0, 0, 0, 0, MAXCOLS, MAXROWS); ximage->data = NULL; XDestroyImage(ximage); XFlush(display_); }
result CMuli3DPresentTargetLinuxX11::Present( const float32 *i_pSource, uint32 i_iFloats ) { m3ddeviceparameters DeviceParameters = m_pParent->GetDeviceParameters(); // Copy pixels to the ximage-buffer --------------------------------------- fpuTruncate(); if( m_iPixelBytes == 2 ) { // 16-bit uint16 *pDestination = (uint16 *)m_pXImage->data; uint32 iPixels = DeviceParameters.iBackbufferWidth * DeviceParameters.iBackbufferHeight; while( iPixels-- ) { const int32 iR = iClamp( ftol( i_pSource[0] * m_i16bitMaxVal[0] ), 0, m_i16bitMaxVal[0] ); const int32 iG = iClamp( ftol( i_pSource[1] * m_i16bitMaxVal[1] ), 0, m_i16bitMaxVal[1] ); const int32 iB = iClamp( ftol( i_pSource[2] * m_i16bitMaxVal[2] ), 0, m_i16bitMaxVal[2] ); i_pSource += i_iFloats; *pDestination++ = ( iR << m_i16bitShift[0] ) | ( iG << m_i16bitShift[1] ) | ( iB << m_i16bitShift[2] ); } } else { // 24- or 32-bit uint8 *pDestination = (uint8 *)m_pXImage->data; uint32 iPixels = DeviceParameters.iBackbufferWidth * DeviceParameters.iBackbufferHeight; while( iPixels-- ) { pDestination[0] = iClamp( ftol( i_pSource[2] * 255.0f ), 0, 255 ); // b pDestination[1] = iClamp( ftol( i_pSource[1] * 255.0f ), 0, 255 ); // g pDestination[2] = iClamp( ftol( i_pSource[0] * 255.0f ), 0, 255 ); // r i_pSource += i_iFloats; pDestination += m_iPixelBytes; } } fpuReset(); // Present to window/screen XPutImage( m_pDisplay, DeviceParameters.hDeviceWindow, m_WindowGC, m_pXImage, 0, 0, 0, 0, DeviceParameters.iBackbufferWidth, DeviceParameters.iBackbufferHeight ); return s_ok; }
/* Taking differences between the values of horizontally adjacent pixels */ void differencex_filter(){ float mask[2]={1,-1}; float rmax, rmin, rng; int i,j; matrix m,dx; /* Fill in the image with background color */ for(i=0; i<IMAGE_WIDTH; i++) for(j=0; j<IMAGE_HEIGHT; j++) XPutPixel(theXImage_2,i,j,bg); /* Clear the drawing window so the image is displayed again */ XClearArea(XtDisplay(draw_1),XtWindow(draw_2),0,0,0,0,True); /* Associate the watch cursor with the main window */ XDefineCursor(XtDisplay(draw_1), XtWindow(main_window), theCursor); /* Flush the request buffer and wait for all events */ /* and errors to be processed by the server. */ XSync(XtDisplay(draw_1), False); for(i=0;i<IMAGE_WIDTH;i++) for(j=0;j<IMAGE_HEIGHT;j++) m[i][j]= XGetPixel(theXImage_1,i,j); convo_vectorx(m, mask, 1, &rmax, &rmin, dx); rng = (rmax-rmin); for(i=0;i<512;i++) for(j=0;j<511;j++){ XPutPixel(theXImage_2,i,j,(unsigned long) (((float)(dx[i][j]-rmin)/rng)*255.0)); } /* Copy image into pixmap */ XPutImage(XtDisplay(draw_2), thePixmap_2, image_gc_2, theXImage_2, 0, 0, 0, 0, theXImage_2->width, theXImage_2->height); /* Disassociate the watch cursor from the main window */ XUndefineCursor(XtDisplay(draw_1), XtWindow(main_window)); /* Clear the drawing window so the image is displayed again */ XClearArea(XtDisplay(draw_2),XtWindow(draw_2),0,0,0,0,True); }
void wsPutImage( wsTWindow * win ) { if ( wsUseXShm ) { XShmPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage, 0,0, ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2, win->xImage->width,win->xImage->height,0 ); } else { XPutImage( wsDisplay,win->WindowID,win->wGC,win->xImage, 0,0, ( win->Width - win->xImage->width ) / 2,( win->Height - win->xImage->height ) / 2, win->xImage->width,win->xImage->height ); } }
int draw_image (ClientData cd, Tcl_Interp *interp, int argc, char **argv) { Tk_Window tkwin; Display *display; Window window; GC gc; Tk_Window interpWin; interpWin=(Tk_Window) cd; tkwin=Tk_NameToWindow (interp,".c",interpWin); display=Tk_Display (tkwin); window=Tk_WindowId (tkwin); gc=Tk_GetGC (tkwin,0,NULL); if (ximage!=NULL) { XPutImage (display,window,gc,ximage,0,0,0,0,RESX,RESY); } return 0; }
static void swrastXPutImage(__DRIdrawable * draw, int op, int srcx, int srcy, int x, int y, int w, int h, int stride, int shmid, char *data, void *loaderPrivate) { struct drisw_drawable *pdp = loaderPrivate; __GLXDRIdrawable *pdraw = &(pdp->base); Display *dpy = pdraw->psc->dpy; Drawable drawable; XImage *ximage; GC gc; if (!pdp->ximage || shmid != pdp->shminfo.shmid) { if (!XCreateDrawable(pdp, shmid, dpy)) return; } switch (op) { case __DRI_SWRAST_IMAGE_OP_DRAW: gc = pdp->gc; break; case __DRI_SWRAST_IMAGE_OP_SWAP: gc = pdp->swapgc; break; default: return; } drawable = pdraw->xDrawable; ximage = pdp->ximage; ximage->bytes_per_line = stride ? stride : bytes_per_line(w * ximage->bits_per_pixel, 32); ximage->data = data; if (pdp->shminfo.shmid >= 0) { ximage->width = ximage->bytes_per_line / ((ximage->bits_per_pixel + 7)/ 8); ximage->height = h; XShmPutImage(dpy, drawable, gc, ximage, srcx, srcy, x, y, w, h, False); XSync(dpy, False); } else { ximage->width = w; ximage->height = h; XPutImage(dpy, drawable, gc, ximage, srcx, srcy, x, y, w, h); } ximage->data = NULL; }
void JXGC::CopyImage ( const XImage* source, const JCoordinate src_x, const JCoordinate src_y, const JCoordinate width, const JCoordinate height, const Drawable dest, const JCoordinate dest_x, const JCoordinate dest_y ) const { XPutImage(*itsDisplay, dest, itsXGC, const_cast<XImage*>(source), src_x, src_y, dest_x, dest_y, width, height); }
static Pixmap xf_mono_bitmap_new(xfContext* xfc, int width, int height, const BYTE* data) { int scanline; XImage* image; Pixmap bitmap; scanline = (width + 7) / 8; bitmap = XCreatePixmap(xfc->display, xfc->drawable, width, height, 1); image = XCreateImage(xfc->display, xfc->visual, 1, ZPixmap, 0, (char*) data, width, height, 8, scanline); image->byte_order = LSBFirst; image->bitmap_bit_order = LSBFirst; XPutImage(xfc->display, bitmap, xfc->gc_mono, image, 0, 0, 0, 0, width, height); image->data = NULL; XDestroyImage(image); return bitmap; }
void DrawImage(char *data, int x, int y, int width, int height) { XImage *xi; if (lsx_curwin->toplevel == NULL || data == NULL) return; xi = XCreateImage(display, DefaultVisual(display, DefaultScreen(display)), 8, ZPixmap, 0, data, width, height, XBitmapPad(display), width); if (xi == NULL) return; XPutImage(display, window, drawgc, xi, 0,0, x,y, xi->width,xi->height); XFree((char *)xi); }
Pixmap xf_glyph_new(xfInfo* xfi, int width, int height, uint8* data) { int scanline; Pixmap bitmap; XImage* image; scanline = (width + 7) / 8; bitmap = XCreatePixmap(xfi->display, xfi->drawable, width, height, 1); image = XCreateImage(xfi->display, xfi->visual, 1, ZPixmap, 0, (char*) data, width, height, 8, scanline); image->byte_order = MSBFirst; image->bitmap_bit_order = MSBFirst; XInitImage(image); XPutImage(xfi->display, bitmap, xfi->gc_mono, image, 0, 0, 0, 0, width, height); XFree(image); return bitmap; }
void window_display_framebuffer(window *wnd) { struct timespec tim; struct timespec tim2; /* copy framebuffer data */ wnd->img->data = (char*)wnd->fb.color; XPutImage(wnd->dpy, wnd->wnd, wnd->gc, wnd->img, 0, 0, 0, 0, wnd->fb.width, wnd->fb.height); wnd->img->data = NULL; /* wait for ~16.666 ms -> ~60 fps */ tim.tv_sec = 0; tim.tv_nsec = 16666666L; nanosleep(&tim, &tim2); }
void wsImageDraw(wsWindow *win) { #ifdef HAVE_SHM if (wsUseXShm) { XShmPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage, 0, 0, (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2, win->xImage->width, win->xImage->height, 0); } else #endif { XPutImage(wsDisplay, win->WindowID, win->wGC, win->xImage, 0, 0, (win->Width - win->xImage->width) / 2, (win->Height - win->xImage->height) / 2, win->xImage->width, win->xImage->height); } }
/** * Display a surface that's in a tiled configuration. That is, all the * pixels for a TILE_SIZExTILE_SIZE block are contiguous in memory. */ static void xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf) { XImage *ximage; struct xm_buffer *xm_buf = xm_buffer( cell_texture(surf->texture)->buffer); const uint tilesPerRow = (surf->width + TILE_SIZE - 1) / TILE_SIZE; uint x, y; ximage = b->tempImage; /* check that the XImage has been previously initialized */ assert(ximage->format); assert(ximage->bitmap_unit); /* update XImage's fields */ ximage->width = TILE_SIZE; ximage->height = TILE_SIZE; ximage->bytes_per_line = TILE_SIZE * 4; for (y = 0; y < surf->height; y += TILE_SIZE) { for (x = 0; x < surf->width; x += TILE_SIZE) { uint tmpTile[TILE_SIZE * TILE_SIZE]; int tx = x / TILE_SIZE; int ty = y / TILE_SIZE; int offset = ty * tilesPerRow + tx; int w = TILE_SIZE; int h = TILE_SIZE; if (y + h > surf->height) h = surf->height - y; if (x + w > surf->width) w = surf->width - x; /* offset in pixels */ offset *= TILE_SIZE * TILE_SIZE; /* twiddle from ximage buffer to temp tile */ twiddle_tile((uint *) xm_buf->data + offset, tmpTile); /* display temp tile data */ ximage->data = (char *) tmpTile; XPutImage(b->xm_visual->display, b->drawable, b->gc, ximage, 0, 0, x, y, w, h); } } }
void DisplayPixRegion(int ilo, int ihi, int jlo, int jhi) { int count, x, y, height, width; y = ilo * scale; x = jlo * scale; height = (ihi - ilo + 1) * scale; width = (jhi - jlo + 1) * scale; XPutImage(display, window, gc, image, x, y, x, y, width, height); XFlush(display); /* for(count = 0; count < rows; count++) { XDrawLine(display, XtWindow(canvas_widget), gc, 0, (overlay_row[count] - 1 - top_edge) * scale, pict_width * scale - 1, (overlay_row[count] - 1 - top_edge) * scale); } for(count = 0; count < cols; count++) { XDrawLine(display, XtWindow(canvas_widget), gc, (overlay_col[count] - 1 - left_edge) * scale, 0, (overlay_col[count] - 1 - left_edge) * scale, pict_height * scale - 1); } */ for(count = 0; count < rows; count++) { XDrawLine(display, XtWindow(canvas_widget), gc, 0, (overlay_row[count] - top_edge + .5) * scale, pict_width * scale - 1, (overlay_row[count] - top_edge + .5) * scale); } for(count = 0; count < cols; count++) { XDrawLine(display, XtWindow(canvas_widget), gc, (overlay_col[count] - left_edge + .5) * scale, 0, (overlay_col[count] - left_edge + .5) * scale, pict_height * scale - 1); } }
int main (int argc, char *argv[]) { int imageWidth; int imageHeight; XImage *img; Window mainWin; unsigned long windowMask; XSetWindowAttributes winAttrib; int screen; Display *dis; GC copyGC; dis = XOpenDisplay (NULL); screen = DefaultScreen (dis); img = create_image_from_buffer (dis, screen, &imageWidth, &imageHeight); windowMask = CWBackPixel | CWBorderPixel; winAttrib.border_pixel = BlackPixel (dis, screen); winAttrib.background_pixel = BlackPixel (dis, screen); winAttrib.override_redirect = 0; mainWin = XCreateWindow (dis, DefaultRootWindow (dis),20, 20,imageWidth,imageHeight,0, DefaultDepth (dis, screen),InputOutput, CopyFromParent,CWBackPixel | CWBorderPixel, &winAttrib); copyGC = XCreateGC (dis, mainWin, 0, NULL); XMapWindow (dis, mainWin); XSelectInput(dis, mainWin, ExposureMask | KeyPressMask); Atom WM_DELETE_WINDOW = XInternAtom(dis, "WM_DELETE_WINDOW", False); XSetWMProtocols(dis, mainWin, &WM_DELETE_WINDOW, 1); while (1) { XEvent event; XNextEvent (dis, &event); switch (event.type) { case Expose: XPutImage (dis, mainWin, copyGC, img, 0, 0, 0, 0, imageWidth, imageHeight); XFlush (dis); break; case KeyPress: if (XK_q == XLookupKeysym (&event.xkey, 0)) { exit (EXIT_SUCCESS); } break; case ClientMessage: XCloseDisplay(dis); exit (EXIT_SUCCESS); break; } } return EXIT_FAILURE; }
/* For each point, evaluate its colour */ static void display_double(int size, double xmin, double xmax, double ymin, double ymax, int yofs, int ylim) { int x, y; double cr, ci; double xscal = (xmax - xmin) / size; double yscal = (ymax - ymin) / size; unsigned counts; #if (OPTIMIZED) cr = xmin; ci = ymin; #endif for (y = yofs ; y < ylim; y++) { for (x = 0; x < size; x++) { #if (!OPTIMIZED) cr = xmin + x * xscal; ci = ymin + y * yscal; #endif counts = mandel_double(cr, ci); ((unsigned *) g_x11.bitmap->data)[x + y*size] = cols[counts]; #if (OPTIMIZED) cr += xscal; #endif } /* Display it line-by-line for speed */ XPutImage(g_x11.dpy, g_x11.win, g_x11.gc, g_x11.bitmap, 0, y, 0, y, size, 1); #if (OPTIMIZED) ci += yscal; #endif } XFlush(g_x11.dpy); }
/* For each point, evaluate its colour */ static void display_float(int width, int height, float xmin, float xmax, float ymin, float ymax, int yofs, int ylim) { int size = width * height; int x; int y; float cr, ci; float xscal = (xmax - xmin) / size; float yscal = (ymax - ymin) / size; unsigned counts; #if (OPTIMIZED) cr = xmin; ci = ymin; #endif for (y = yofs; y < ylim; y++) { for (x = 0; x < width; x++) { #if (!OPTIMIZED) cr = xmin + x * xscal; ci = ymin + y * yscal; #endif counts = mandel_float(cr, ci); ((unsigned *) g_x11.bitmap->data)[x + y*width] = cols[counts]; #if (OPTIMIZED) cr += xscal; #endif } /* Display it line-by-line for speed */ XPutImage(g_x11.dpy, g_x11.win, g_x11.gc, g_x11.bitmap, 0, y, 0, y, width, 1); #if (OPTIMIZED) ci += yscal; #endif } XFlush(g_x11.dpy); }