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

📄 gui.c

📁 GTK SWF Player. GNOME Applications and a mozilla plugin. Other things included is a library for read
💻 C
字号:
/* * Copyright (c) 2002, Bob Doan * *---------------------------------------------------------------------- * This file is part of tubesock - the GTK/GNOME swf player. * *  tubesock is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  tubesock is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with tubesock; if not, write to the Free Software *  Foundation, Inc.: *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *---------------------------------------------------------------------- */#include <tubesock.h>#include <string.h>struct tubesock * swf_gui_init(struct swf_file *swf, GtkWidget *root_window, GtkWidget *main_vbox) {	struct tubesock *ts = malloc(sizeof(struct tubesock));	GtkWidget *fixed;	fixed = gtk_fixed_new ();	gtk_widget_set_size_request (GTK_WIDGET (fixed), SWF_TO_PIXEL(swf->header.framesize.max_x), SWF_TO_PIXEL(swf->header.framesize.max_y));	gtk_container_add (GTK_CONTAINER (main_vbox), fixed);	ts->swf = swf;	ts->vbox = main_vbox;	ts->root_window = root_window;	ts->container = fixed;	ts->objects = NULL;	gtk_widget_show (fixed);	return ts;}void hack_shape (struct tubesock_doit *wtf){	struct swf_element *c;	struct swf_element *sr;	struct swf_element *xxx;	struct swf_type_defineshape3 *ds = wtf->e->data;	struct swf_type_shapewithstyle *sws=&ds->info;	struct swf_type_shape *shape = &sws->shape;	int XOFFSET = ds->shapeBounds.min_x;	int YOFFSET = ds->shapeBounds.min_y;	struct swf_type_linestylearray *lsa;	struct swf_element *elsa;	struct swf_type_linestyle *ls;	GdkGC* gc=NULL;	sr = shape->shaperecs;	lsa = &sws->lsa;	for(elsa = lsa->linestyle; elsa != NULL; elsa = elsa->next) {		GdkColor color1;		ls = (struct swf_type_linestyle *)elsa->data;		printf("WIDTH = %d\n", SWF_TO_PIXEL(ls->width));		color1.pixel = 0x0;		if(ls->rgba) {			GdkColormap *mark = gdk_colormap_get_system();			struct swf_type_rgba *rgb = ls->color;			color1.red = ((float)(rgb->r/255.0))*0xFFFF;			color1.green = ((float)(rgb->g/255.0))*0xFFFF;			color1.blue = ((float)(rgb->b/255.0))*0xFFFF;			gdk_color_alloc(mark, &color1);			printf("R=%d G=%d B=%d r=%d g=%d b=%d\n", color1.red, color1.green, color1.blue, rgb->r, rgb->g, rgb->b);		} else {			struct swf_type_rgb *rgb = ls->color;			color1.red = (float)(rgb->r/0xFF)*0xFFFF;			color1.green = (float)(rgb->g/0xFF)*0xFFFF;			color1.blue = (float)(rgb->b/0xFF)*0xFFFF;			printf("R=%d G=%d B=%d\n", color1.red, color1.green, color1.blue);		}		gc = gdk_gc_new(wtf->pixmap);		gdk_gc_set_foreground (gc, &color1);		gdk_gc_set_line_attributes(gc, SWF_TO_PIXEL(ls->width), GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND);	}		while(sr != NULL) {		c = sr->data;		while(c != NULL) {			xxx = c->data;			while(xxx != NULL) {				if(xxx->type == SWF_TYPE_SHAPEREC_MOVETO) {					struct swf_type_shaperec_change_moveto *d = xxx->data;					shape->x = SWF_TO_PIXEL((d->x-XOFFSET));					shape->y = SWF_TO_PIXEL((d->y-YOFFSET));					printf("MoveTo: %d %d\n",  shape->x, shape->y);				}				else if(xxx->type == SWF_TYPE_SHAPEREC_LINETO) {					struct swf_type_shaperec_change_lineto *d = xxx->data;					gdk_draw_line (wtf->pixmap, gc, shape->x, shape->y, shape->x+SWF_TO_PIXEL((d->x)), shape->y+SWF_TO_PIXEL((d->y)));					shape->x += SWF_TO_PIXEL((d->x));					shape->y += SWF_TO_PIXEL((d->y));					printf("LineTo: %d %d\n", shape->x, shape->y);					}					else if(xxx->type == SWF_TYPE_SHAPEREC_VLINETO) {					struct swf_type_shaperec_change_vlineto *d = xxx->data;					gdk_draw_line (wtf->pixmap, gc, shape->x, shape->y, shape->x, shape->y+SWF_TO_PIXEL((d->y)));					shape->y += SWF_TO_PIXEL((d->y));					printf("VLineTo: %d\n", shape->y);					}					else if(xxx->type == SWF_TYPE_SHAPEREC_HLINETO) {					struct swf_type_shaperec_change_hlineto *d = xxx->data;					gdk_draw_line (wtf->pixmap, gc, shape->x, shape->y, shape->x+SWF_TO_PIXEL((d->x)), shape->y);					shape->x += SWF_TO_PIXEL((d->x));					printf("HLineTo: %d\n", shape->x);					} else {					printf("NOT IMPLEMENTED :(\n");								}								xxx = xxx->next;			}			c = c->next;		}				sr = sr->next;	}}void figureoutbitmap(struct tubesock_doit *wtf) {	guchar *data = gdk_pixbuf_get_pixels(wtf->pixbuf);	guchar r,g,b;	guchar *bmdata = (guchar *) g_malloc ((50 * 50));	int x,y, height=gdk_pixbuf_get_height(wtf->pixbuf), width=gdk_pixbuf_get_width (wtf->pixbuf), rs=gdk_pixbuf_get_rowstride (wtf->pixbuf);	int foo=(50/8)+1;	memset(bmdata, 0, (50*50));	for(y=0;y<height;y++) {		for(x=0;x<width;x++) {			r = data[(y*rs)+(x*3)+0];			g = data[(y*rs)+(x*3)+1];			b = data[(y*rs)+(x*3)+2];			if(r != 0xFF && g != 0xFF && b != 0xFF) {				bmdata[(y*foo)+(x/8)] |= (1<<(x%8));			} else {			}		}	}	wtf->bitmap = gdk_bitmap_create_from_data (NULL, bmdata,50, 50);}struct swf_element *swf_gui_run(struct tubesock *ts, struct swf_element *e) {	struct tubesock_doit *wtf;	if(e == NULL)		e = ts->swf->elements;	if(e->type == SWF_TYPE_DEFINESHAPE3) {		struct swf_type_defineshape3 *ds = e->data;		wtf = malloc(sizeof(struct tubesock_doit));						wtf->ts = ts;		wtf->e = e;		wtf->pixmap = NULL;		wtf->bitmap = NULL;		wtf->image = NULL;				wtf->pixmap = gdk_pixmap_new(ts->root_window->window,  SWF_TO_PIXEL(ds->shapeBounds.max_x)-SWF_TO_PIXEL(ds->shapeBounds.min_x), SWF_TO_PIXEL(ds->shapeBounds.max_y)-SWF_TO_PIXEL(ds->shapeBounds.min_y), -1);		gdk_draw_rectangle (wtf->pixmap, ts->root_window->style->white_gc, TRUE, 0, 0,  SWF_TO_PIXEL(ds->shapeBounds.max_x)-SWF_TO_PIXEL(ds->shapeBounds.min_x), SWF_TO_PIXEL(ds->shapeBounds.max_y)-SWF_TO_PIXEL(ds->shapeBounds.min_y));		hack_shape(wtf);		wtf->pixbuf = gdk_pixbuf_get_from_drawable(NULL,wtf->pixmap,gdk_drawable_get_colormap(wtf->pixmap),0,0,0,0, SWF_TO_PIXEL(ds->shapeBounds.max_x)-SWF_TO_PIXEL(ds->shapeBounds.min_x), SWF_TO_PIXEL(ds->shapeBounds.max_y)-SWF_TO_PIXEL(ds->shapeBounds.min_y));		wtf->bitmap = gdk_pixmap_new(ts->root_window->window,  SWF_TO_PIXEL(ds->shapeBounds.max_x)-SWF_TO_PIXEL(ds->shapeBounds.min_x), SWF_TO_PIXEL(ds->shapeBounds.max_y)-SWF_TO_PIXEL(ds->shapeBounds.min_y), 1);					figureoutbitmap(wtf);		wtf->image = gtk_image_new_from_pixmap (wtf->pixmap, wtf->bitmap);		gtk_fixed_put (GTK_FIXED (ts->container), wtf->image, SWF_TO_PIXEL(ds->shapeBounds.min_x), SWF_TO_PIXEL(ds->shapeBounds.min_y));		swf_addElement(ts->swf, &ts->objects, swf_element_New(ds->shapeid, wtf));	} else if(e->type == SWF_TYPE_PLACEOBJECT2) {		struct swf_type_placeobject2 *po = e->data;		struct swf_element *tmp;		for(tmp=ts->objects;tmp != NULL; tmp=tmp->next) {			if(tmp->type == po->characterid) {				struct tubesock_doit *wtf = tmp->data;				gtk_widget_show(wtf->image);					break;			}		}	}		e = e->next;	return e;}

⌨️ 快捷键说明

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