⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tkbitmap.c

📁 linux系统下的音频通信
💻 C
📖 第 1 页 / 共 2 页
字号:
    predefPtr->width = width;    predefPtr->height = height;    predefPtr->native = 0;    Tcl_SetHashValue(predefHashPtr, predefPtr);    return TCL_OK;}/* *-------------------------------------------------------------- * * Tk_NameOfBitmap -- * *	Given a bitmap, return a textual string identifying the *	bitmap. * * Results: *	The return value is the string name associated with bitmap. * * Side effects: *	None. * *-------------------------------------------------------------- */Tk_UidTk_NameOfBitmap(display, bitmap)    Display *display;			/* Display for which bitmap was					 * allocated. */    Pixmap bitmap;			/* Bitmap whose name is wanted. */{    IdKey idKey;    Tcl_HashEntry *idHashPtr;    TkBitmap *bitmapPtr;    if (!initialized) {	unknown:	panic("Tk_NameOfBitmap received unknown bitmap argument");    }    idKey.display = display;    idKey.pixmap = bitmap;    idHashPtr = Tcl_FindHashEntry(&idTable, (char *) &idKey);    if (idHashPtr == NULL) {	goto unknown;    }    bitmapPtr = (TkBitmap *) Tcl_GetHashValue(idHashPtr);    return ((NameKey *) bitmapPtr->hashPtr->key.words)->name;}/* *-------------------------------------------------------------- * * Tk_SizeOfBitmap -- * *	Given a bitmap managed by this module, returns the width *	and height of the bitmap. * * Results: *	The words at *widthPtr and *heightPtr are filled in with *	the dimenstions of bitmap. * * Side effects: *	If bitmap isn't managed by this module then the procedure *	panics.. * *-------------------------------------------------------------- */voidTk_SizeOfBitmap(display, bitmap, widthPtr, heightPtr)    Display *display;			/* Display for which bitmap was					 * allocated. */    Pixmap bitmap;			/* Bitmap whose size is wanted. */    int *widthPtr;			/* Store bitmap width here. */    int *heightPtr;			/* Store bitmap height here. */{    IdKey idKey;    Tcl_HashEntry *idHashPtr;    TkBitmap *bitmapPtr;    if (!initialized) {	unknownBitmap:	panic("Tk_SizeOfBitmap received unknown bitmap argument");    }    idKey.display = display;    idKey.pixmap = bitmap;    idHashPtr = Tcl_FindHashEntry(&idTable, (char *) &idKey);    if (idHashPtr == NULL) {	goto unknownBitmap;    }    bitmapPtr = (TkBitmap *) Tcl_GetHashValue(idHashPtr);    *widthPtr = bitmapPtr->width;    *heightPtr = bitmapPtr->height;}/* *---------------------------------------------------------------------- * * Tk_FreeBitmap -- * *	This procedure is called to release a bitmap allocated by *	Tk_GetBitmap or TkGetBitmapFromData. * * Results: *	None. * * Side effects: *	The reference count associated with bitmap is decremented, and *	it is officially deallocated if no-one is using it anymore. * *---------------------------------------------------------------------- */voidTk_FreeBitmap(display, bitmap)    Display *display;			/* Display for which bitmap was					 * allocated. */    Pixmap bitmap;			/* Bitmap to be released. */{    Tcl_HashEntry *idHashPtr;    register TkBitmap *bitmapPtr;    IdKey idKey;    if (!initialized) {	panic("Tk_FreeBitmap called before Tk_GetBitmap");    }    idKey.display = display;    idKey.pixmap = bitmap;    idHashPtr = Tcl_FindHashEntry(&idTable, (char *) &idKey);    if (idHashPtr == NULL) {	panic("Tk_FreeBitmap received unknown bitmap argument");    }    bitmapPtr = (TkBitmap *) Tcl_GetHashValue(idHashPtr);    bitmapPtr->refCount--;    if (bitmapPtr->refCount == 0) {	Tk_FreePixmap(bitmapPtr->display, bitmapPtr->bitmap);	Tcl_DeleteHashEntry(idHashPtr);	Tcl_DeleteHashEntry(bitmapPtr->hashPtr);	ckfree((char *) bitmapPtr);    }}/* *---------------------------------------------------------------------- * * Tk_GetBitmapFromData -- * *	Given a description of the bits for a bitmap, make a bitmap that *	has the given properties. *** NOTE:  this procedure is obsolete *	and really shouldn't be used anymore. *** * * Results: *	The return value is the X identifer for the desired bitmap *	(a one-plane Pixmap), unless it couldn't be created properly. *	In this case, None is returned and an error message is left in *	interp->result.  The caller should never modify the bitmap that *	is returned, and should eventually call Tk_FreeBitmap when the *	bitmap is no longer needed. * * Side effects: *	The bitmap is added to an internal database with a reference count. *	For each call to this procedure, there should eventually be a call *	to Tk_FreeBitmap, so that the database can be cleaned up when bitmaps *	aren't needed anymore. * *---------------------------------------------------------------------- */	/* ARGSUSED */PixmapTk_GetBitmapFromData(interp, tkwin, source, width, height)    Tcl_Interp *interp;		/* Interpreter to use for error reporting. */    Tk_Window tkwin;		/* Window in which bitmap will be used. */    char *source;		/* Bitmap data for bitmap shape. */    int width, height;		/* Dimensions of bitmap. */{    DataKey nameKey;    Tcl_HashEntry *dataHashPtr;    Tk_Uid name;    int new;    char string[20];    static int autoNumber = 0;    if (!initialized) {	BitmapInit();    }    nameKey.source = source;    nameKey.width = width;    nameKey.height = height;    dataHashPtr = Tcl_CreateHashEntry(&dataTable, (char *) &nameKey, &new);    if (!new) {	name = (Tk_Uid) Tcl_GetHashValue(dataHashPtr);    } else {	autoNumber++;	sprintf(string, "_tk%d", autoNumber);	name = Tk_GetUid(string);	Tcl_SetHashValue(dataHashPtr, name);	if (Tk_DefineBitmap(interp, name, source, width, height) != TCL_OK) {	    Tcl_DeleteHashEntry(dataHashPtr);	    return TCL_ERROR;	}    }    return Tk_GetBitmap(interp, tkwin, name);}/* *---------------------------------------------------------------------- * * BitmapInit -- * *	Initialize the structures used for bitmap management. * * Results: *	None. * * Side effects: *	Read the code. * *---------------------------------------------------------------------- */static voidBitmapInit(){    Tcl_Interp *dummy;    dummy = Tcl_CreateInterp();    initialized = 1;    Tcl_InitHashTable(&nameTable, sizeof(NameKey)/sizeof(int));    Tcl_InitHashTable(&dataTable, sizeof(DataKey)/sizeof(int));    Tcl_InitHashTable(&tkPredefBitmapTable, TCL_ONE_WORD_KEYS);    /*     * The call below is tricky:  can't use sizeof(IdKey) because it     * gets padded with extra unpredictable bytes on some 64-bit     * machines.     */    Tcl_InitHashTable(&idTable, (sizeof(Display *) + sizeof(Pixmap))	    /sizeof(int));    Tk_DefineBitmap(dummy, Tk_GetUid("error"), (char *) error_bits,	    error_width, error_height);    Tk_DefineBitmap(dummy, Tk_GetUid("gray75"), (char *) gray75_bits,	    gray75_width, gray75_height);    Tk_DefineBitmap(dummy, Tk_GetUid("gray50"), (char *) gray50_bits,	    gray50_width, gray50_height);    Tk_DefineBitmap(dummy, Tk_GetUid("gray25"), (char *) gray25_bits,	    gray25_width, gray25_height);    Tk_DefineBitmap(dummy, Tk_GetUid("gray12"), (char *) gray12_bits,	    gray12_width, gray12_height);    Tk_DefineBitmap(dummy, Tk_GetUid("hourglass"), (char *) hourglass_bits,	    hourglass_width, hourglass_height);    Tk_DefineBitmap(dummy, Tk_GetUid("info"), (char *) info_bits,	    info_width, info_height);    Tk_DefineBitmap(dummy, Tk_GetUid("questhead"), (char *) questhead_bits,	    questhead_width, questhead_height);    Tk_DefineBitmap(dummy, Tk_GetUid("question"), (char *) question_bits,	    question_width, question_height);    Tk_DefineBitmap(dummy, Tk_GetUid("warning"), (char *) warning_bits,	    warning_width, warning_height);    TkpDefineNativeBitmaps();    Tcl_DeleteInterp(dummy);}/* *---------------------------------------------------------------------- * * TkReadBitmapFile -- * *	Loads a bitmap image in X bitmap format into the specified *	drawable.  This is equivelent to the XReadBitmapFile in X. * * Results: *	Sets the size, hotspot, and bitmap on success. * * Side effects: *	Creates a new bitmap from the file data. * *---------------------------------------------------------------------- */intTkReadBitmapFile(display, d, filename, width_return, height_return,	bitmap_return, x_hot_return, y_hot_return)     Display* display;    Drawable d;    CONST char* filename;    unsigned int* width_return;    unsigned int* height_return;    Pixmap* bitmap_return;    int* x_hot_return;    int* y_hot_return;{    char *data;    data = TkGetBitmapData(NULL, NULL, (char *) filename,	    (int *) width_return, (int *) height_return, x_hot_return,	    y_hot_return);    if (data == NULL) {	return BitmapFileInvalid;    }    *bitmap_return = XCreateBitmapFromData(display, d, data, *width_return,	    *height_return);    ckfree(data);    return BitmapSuccess;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -