void DisplayCb_1 (AVFrame *Frame) { //LOGI("%s : %d\n",__func__,__LINE__); //send data back to java side to display fill_bitmap(&info, pixel1, Frame); return_Message_to_Java("disp1"); }
bool load_bits_only(Byte* bytes, int bits_size, int width, int height) { close(); memset(&file_header, 0, sizeof(BITMAPFILEHEADER)); file_header.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + bits_size; file_header.bfType = 0x4d42; file_header.bfOffBits = 0x36; info_header = create_info_header(width, height); return fill_bitmap(bytes, bits_size); }
bool load_bits_and_headers(Byte* bytes) { close(); int pos = 0; memcpy(&file_header, bytes + pos, sizeof(BITMAPFILEHEADER)); pos += sizeof(BITMAPFILEHEADER); memcpy(&info_header, bytes + pos, sizeof(BITMAPINFOHEADER)); pos += sizeof(BITMAPINFOHEADER); return fill_bitmap(bytes + pos, bits_size()); }
void Fake_glXUseXFont(Font font, int first, int count, int listbase) { Display *dpy; Window win; Pixmap pixmap; GC gc; XGCValues values; unsigned long valuemask; XFontStruct *fs; GLint swapbytes, lsbfirst, rowlength; GLint skiprows, skippixels, alignment; unsigned int max_width, max_height, max_bm_width, max_bm_height; GLubyte *bm; int i; dpy = glXGetCurrentDisplay(); if (!dpy) return; /* I guess glXMakeCurrent wasn't called */ win = RootWindow(dpy, DefaultScreen(dpy)); fs = XQueryFont(dpy, font); if (!fs) { _mesa_error(NULL, GL_INVALID_VALUE, "Couldn't get font structure information"); return; } /* Allocate a bitmap that can fit all characters. */ max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing; max_height = fs->max_bounds.ascent + fs->max_bounds.descent; max_bm_width = (max_width + 7) / 8; max_bm_height = max_height; bm = malloc((max_bm_width * max_bm_height) * sizeof(GLubyte)); if (!bm) { XFreeFontInfo(NULL, fs, 1); _mesa_error(NULL, GL_OUT_OF_MEMORY, "Couldn't allocate bitmap in glXUseXFont()"); return; } #if 0 /* get the page info */ pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1; firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2; lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2; rows = fs->max_byte1 - fs->min_byte1 + 1; unsigned int first_char, last_char, pages, rows; #endif /* Save the current packing mode for bitmaps. */ glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes); glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst); glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength); glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows); glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels); glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); /* Enforce a standard packing mode which is compatible with fill_bitmap() from above. This is actually the default mode, except for the (non)alignment. */ glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); pixmap = XCreatePixmap(dpy, win, 10, 10, 1); values.foreground = BlackPixel(dpy, DefaultScreen(dpy)); values.background = WhitePixel(dpy, DefaultScreen(dpy)); values.font = fs->fid; valuemask = GCForeground | GCBackground | GCFont; gc = XCreateGC(dpy, pixmap, valuemask, &values); XFreePixmap(dpy, pixmap); #ifdef DEBUG if (debug_xfonts) dump_font_struct(fs); #endif for (i = 0; i < count; i++) { unsigned int width, height, bm_width, bm_height; GLfloat x0, y0, dx, dy; XCharStruct *ch; int x, y; unsigned int c = first + i; int list = listbase + i; int valid; /* check on index validity and get the bounds */ ch = isvalid(fs, c); if (!ch) { ch = &fs->max_bounds; valid = 0; } else { valid = 1; } #ifdef DEBUG if (debug_xfonts) { char s[7]; sprintf(s, isprint(c) ? "%c> " : "\\%03o> ", c); dump_char_struct(ch, s); } #endif /* glBitmap()' parameters: straight from the glXUseXFont(3) manpage. */ width = ch->rbearing - ch->lbearing; height = ch->ascent + ch->descent; x0 = -ch->lbearing; y0 = ch->descent - 0; /* XXX used to subtract 1 here */ /* but that caused a conformace failure */ dx = ch->width; dy = 0; /* X11's starting point. */ x = -ch->lbearing; y = ch->ascent; /* Round the width to a multiple of eight. We will use this also for the pixmap for capturing the X11 font. This is slightly inefficient, but it makes the OpenGL part real easy. */ bm_width = (width + 7) / 8; bm_height = height; glNewList(list, GL_COMPILE); if (valid && (bm_width > 0) && (bm_height > 0)) { memset(bm, '\0', bm_width * bm_height); fill_bitmap(dpy, win, gc, bm_width, bm_height, x, y, c, bm); glBitmap(width, height, x0, y0, dx, dy, bm); #ifdef DEBUG if (debug_xfonts) { printf("width/height = %u/%u\n", width, height); printf("bm_width/bm_height = %u/%u\n", bm_width, bm_height); dump_bitmap(bm_width, bm_height, bm); } #endif } else { glBitmap(0, 0, 0.0, 0.0, dx, dy, NULL); } glEndList(); } free(bm); XFreeFontInfo(NULL, fs, 1); XFreeGC(dpy, gc); /* Restore saved packing modes. */ glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes); glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst); glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength); glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels); glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); }
/** * Just like glXUseXFont() but with a rotation parameter. * \param rotation may be 0, 90, 180 or 270 only. */ void glXUseRotatedXFontMESA(Font font, int first, int count, int listbase, int rotation) { Display *dpy; Window win; Pixmap pixmap; GC gc; XFontStruct *fs; GLint swapbytes, lsbfirst, rowlength; GLint skiprows, skippixels, alignment; unsigned int maxCharWidth, maxCharHeight; GLubyte *bm; int i; if (rotation != 0 && rotation != 90 && rotation != 180 && rotation != 270) return; dpy = glXGetCurrentDisplay(); if (!dpy) return; /* I guess glXMakeCurrent wasn't called */ win = RootWindow(dpy, DefaultScreen(dpy)); fs = XQueryFont(dpy, font); if (!fs) { fprintf(stderr, "XQueryFont failed"); return; } /* Allocate a GL bitmap that can fit any character */ maxCharWidth = fs->max_bounds.rbearing - fs->min_bounds.lbearing; maxCharHeight = fs->max_bounds.ascent + fs->max_bounds.descent; /* use max, in case we're rotating */ if (rotation == 90 || rotation == 270) { /* swap width/height */ bm = (GLubyte *) malloc((maxCharHeight + 7) / 8 * maxCharWidth); } else { /* normal or upside down */ bm = (GLubyte *) malloc((maxCharWidth + 7) / 8 * maxCharHeight); } if (!bm) { XFreeFontInfo(NULL, fs, 1); fprintf(stderr, "Out of memory in glXUseRotatedXFontMESA"); return; } /* Save the current packing mode for bitmaps. */ glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes); glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst); glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength); glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows); glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels); glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); /* Enforce a standard packing mode which is compatible with fill_bitmap() from above. This is actually the default mode, except for the (non)alignment. */ glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE); glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); /* Create pixmap and GC */ pixmap = XCreatePixmap(dpy, win, maxCharWidth, maxCharHeight, 1); { XGCValues values; unsigned long valuemask; values.foreground = BlackPixel(dpy, DefaultScreen(dpy)); values.background = WhitePixel(dpy, DefaultScreen(dpy)); values.font = fs->fid; valuemask = GCForeground | GCBackground | GCFont; gc = XCreateGC(dpy, pixmap, valuemask, &values); } for (i = 0; i < count; i++) { const unsigned int c = first + i; const int list = listbase + i; unsigned int charWidth, charHeight; unsigned int bitmapWidth, bitmapHeight; GLfloat xOrig, yOrig, xStep, yStep, dtemp; const XCharStruct *ch; int xPos, yPos; int valid; /* check on index validity and get the bounds */ ch = isvalid(fs, c); if (!ch) { ch = &fs->max_bounds; valid = 0; } else { valid = 1; } /* glBitmap()' parameters: straight from the glXUseXFont(3) manpage. */ charWidth = ch->rbearing - ch->lbearing; charHeight = ch->ascent + ch->descent; xOrig = -ch->lbearing; yOrig = ch->descent; xStep = ch->width; yStep = 0; /* X11's starting point. */ xPos = -ch->lbearing; yPos = ch->ascent; /* Apply rotation */ switch (rotation) { case 0: /* nothing */ bitmapWidth = charWidth; bitmapHeight = charHeight; break; case 90: /* xStep, yStep */ dtemp = xStep; xStep = -yStep; yStep = dtemp; /* xOrig, yOrig */ yOrig = xOrig; xOrig = charHeight - (charHeight - yPos); /* width, height */ bitmapWidth = charHeight; bitmapHeight = charWidth; break; case 180: /* xStep, yStep */ xStep = -xStep; yStep = -yStep; /* xOrig, yOrig */ xOrig = charWidth - xOrig - 1; yOrig = charHeight - yOrig - 1; bitmapWidth = charWidth; bitmapHeight = charHeight; break; case 270: /* xStep, yStep */ dtemp = xStep; xStep = yStep; yStep = -dtemp; /* xOrig, yOrig */ dtemp = yOrig; yOrig = charWidth - xOrig; xOrig = dtemp; /* width, height */ bitmapWidth = charHeight; bitmapHeight = charWidth; break; default: /* should never get here */ ; } glNewList(list, GL_COMPILE); if (valid && bitmapWidth > 0 && bitmapHeight > 0) { fill_bitmap(dpy, pixmap, gc, bitmapWidth, bitmapHeight, charWidth, charHeight, xPos, yPos, c, bm, rotation); glBitmap(bitmapWidth, bitmapHeight, xOrig, yOrig, xStep, yStep, bm); } else { glBitmap(0, 0, 0.0, 0.0, xStep, yStep, NULL); } glEndList(); } free(bm); XFreeFontInfo(NULL, fs, 1); XFreePixmap(dpy, pixmap); XFreeGC(dpy, gc); /* Restore saved packing modes. */ glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes); glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst); glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength); glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows); glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels); glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); }
void DisplayCb_4 (AVFrame *Frame) { // LOGI("%s : %d\n",__func__,__LINE__); fill_bitmap(&info, pixel4, Frame); return_Message_to_Java("disp4"); }