예제 #1
0
파일: init.c 프로젝트: 99years/plan9
/*
 * Attach, or possibly reattach, to window.
 * If reattaching, maintain value of screen pointer.
 */
int
gengetwindow(Display *d, char *winname, Image **winp, Screen **scrp, int ref)
{
	int n, fd;
	char buf[64+1];
	Image *image;
	Rectangle r;

	fd = open(winname, OREAD);
	if(fd<0 || (n=read(fd, buf, sizeof buf-1))<=0){
		if((image=d->image) == nil){
			fprint(2, "gengetwindow: %r\n");
			*winp = nil;
			d->screenimage = nil;
			return -1;
		}
		strcpy(buf, "noborder");
	}else{
		close(fd);
		buf[n] = '\0';
		if(*winp != nil){
			_freeimage1(*winp);
			freeimage((*scrp)->image);
			freescreen(*scrp);
			*scrp = nil;
		}
		image = namedimage(d, buf);
		if(image == 0){
			fprint(2, "namedimage %s failed: %r\n", buf);
			*winp = nil;
			d->screenimage = nil;
			return -1;
		}
		assert(image->chan != 0);
	}

	d->screenimage = image;
	*scrp = allocscreen(image, d->white, 0);
	if(*scrp == nil){
		freeimage(d->screenimage);
		*winp = nil;
		d->screenimage = nil;
		return -1;
	}

	r = image->r;
	if(strncmp(buf, "noborder", 8) != 0)
		r = insetrect(image->r, Borderwidth);
	*winp = _allocwindow(*winp, *scrp, r, ref, DWhite);
	if(*winp == nil){
		freescreen(*scrp);
		*scrp = nil;
		freeimage(image);
		d->screenimage = nil;
		return -1;
	}
	d->screenimage = *winp;
	assert((*winp)->chan != 0);
	return 1;
}
예제 #2
0
파일: VPicEx.cpp 프로젝트: Guokr1991/Hough
//1999-02-19,鲍捷,阴影效果
BOOL VPicEx::DropShadow()
{
   imgdes *srcimg=GetImgDes();

   imgdes tmpsrc, tmpmask;
   int rcode = NO_ERROR, j,
	   shadow_width=20, 
	   shadow_height=20,
	   cols, rows;
   cols = CALC_WIDTH(srcimg);
   rows = CALC_HEIGHT(srcimg);
   allocimage(&tmpsrc, cols, rows, srcimg->bmh->biBitCount);
   allocimage(&tmpmask, cols, rows, srcimg->bmh->biBitCount);
   zeroimage(255, &tmpsrc);
   tmpsrc.stx=shadow_width;
   tmpsrc.sty=shadow_width;  
   copyimage(srcimg, &tmpsrc);
   tmpsrc.stx = 0;
   tmpsrc.sty = 0;   
   kodalith(230, &tmpsrc, &tmpsrc);//二值化,门限230
				 //门限以上的像素被认为白色,不产生阴影
   negative(&tmpsrc, &tmpmask);  
   changebright(128, &tmpsrc, &tmpsrc);
   for(j=0; j<10; j++)     
	   blur(&tmpsrc, &tmpsrc);  
		//使阴影模糊。循环越多越模糊,扩散越大
   tmpmask.stx=shadow_width;
   tmpmask.sty=shadow_width;  
   addimage(&tmpsrc, &tmpmask, &tmpsrc);   
   andimage(srcimg, &tmpsrc, srcimg); 
   freeimage(&tmpmask);
   freeimage(&tmpsrc); 
   return(rcode == NO_ERROR);
}
예제 #3
0
파일: VPicEx.cpp 프로젝트: Guokr1991/Hough
//1999-02-09,鲍捷,浮雕效果
//只对灰度图像有效
BOOL VPicEx::TrueEmboss()
{
	if( !IsValid() ) return FALSE;

	imgdes *srcimg=GetImgDes();
//	colortogray(srcimg,srcimg); 

   imgdes image1;  
   imgdes image2;   
   imgdes tmpsrc; 
   int cols, rows, rcode;
   char  kern1[10] = {-2,-2,0,-2,6,0,0,0,0,1};
   char  kern2[10] = {0,0,0,0,-6,2,0,2,2,1};  
   cols = CALC_WIDTH(srcimg);
   rows = CALC_HEIGHT(srcimg);
   allocimage(&tmpsrc, cols, rows, 8); // Assumes 8-bit source image
   copyimage(srcimg, &tmpsrc);    
   allocimage(&image1, cols, rows, 8);
   allocimage(&image2, cols, rows, 8); 
   matrixconv(kern1, &tmpsrc, &image1);
   matrixconv(kern2, &tmpsrc, &image2); 
   zeroimage(128, &tmpsrc);
   addimage(&tmpsrc, &image1, &tmpsrc); 
   subimage(&tmpsrc, &image2, &tmpsrc);
   rcode = copyimage(&tmpsrc, srcimg); // Assumes 8-bit result image 
   freeimage(&image2);  
   freeimage(&image1); 
   freeimage(&tmpsrc);
   return(rcode == NO_ERROR);

}
예제 #4
0
void
frinittick(Frame *f)
{
	Image *b;
	Font *ft;

	b = f->display->screenimage;
	ft = f->font;
	if(f->tick)
		freeimage(f->tick);
	f->tick = allocimage(f->display, Rect(0, 0, FRTICKW, ft->height), b->chan, 0, DWhite);
	if(f->tick == nil)
		return;
	if(f->tickback)
		freeimage(f->tickback);
	f->tickback = allocimage(f->display, f->tick->r, b->chan, 0, DWhite);
	if(f->tickback == 0){
		freeimage(f->tick);
		f->tick = 0;
		return;
	}
	/* background color */
	draw(f->tick, f->tick->r, f->cols[BACK], nil, ZP);
	/* vertical line */
	draw(f->tick, Rect(FRTICKW/2, 0, FRTICKW/2+1, ft->height), f->display->black, nil, ZP);
	/* box on each end */
	draw(f->tick, Rect(0, 0, FRTICKW, FRTICKW), f->cols[TEXT], nil, ZP);
	draw(f->tick, Rect(0, ft->height-FRTICKW, FRTICKW, ft->height), f->cols[TEXT], nil, ZP);
}
예제 #5
0
파일: VPicEx.cpp 프로젝트: Guokr1991/Hough
//1999-02-18,鲍捷,胶粒效果
BOOL VPicEx::Pointillistic()
{
   imgdes *srcimg=GetImgDes();

	imgdes tmpsrc, tmp8;
	int cols, rows, rcode;
	static char kern1[10] = {0,-1,0,-1,5,-1,0,-1,0,1};
   	cols = CALC_WIDTH(srcimg);  
	rows = CALC_HEIGHT(srcimg);
   allocimage(&tmpsrc, cols, rows, 24);  
   allocimage(&tmp8, cols, rows, 8);   
   if(srcimg->bmh->biBitCount == 8) 
   {    
	   convertpaltorgb(srcimg, &tmpsrc);
   } 
   else 
   {   
	   copyimage(srcimg, &tmpsrc);  
   }
   removenoise(&tmpsrc, &tmpsrc);
   convertrgbtopalex(200, &tmpsrc, &tmp8, CR_OCTREEDIFF);
   convertpaltorgb(&tmp8, &tmpsrc);  
   freeimage(&tmp8);
   matrixconv(kern1, &tmpsrc, &tmpsrc);  
   if(srcimg->bmh->biBitCount == 8)
   {
      rcode = convertrgbtopal(256, &tmpsrc, srcimg); 
   } 
   else 
   {
      rcode = copyimage(&tmpsrc, srcimg);   
   } 
   freeimage(&tmpsrc);
   return(rcode == NO_ERROR);
}
예제 #6
0
파일: scrl.c 프로젝트: AustenConrad/plan-9
void
scrlresize(void)
{
	freeimage(vscrtmp);
	freeimage(hscrtmp);
	vscrtmp = eallocimage(display, Rect(0, 0, 32, screen->r.max.y), screen->chan, 0, DNofill);
	hscrtmp = eallocimage(display, Rect(0, 0, screen->r.max.x, 32), screen->chan, 0, DNofill);
}
예제 #7
0
파일: getdefont.c 프로젝트: 00001/plan9port
Subfont*
getdefont(Display *d)
{
	char *hdr, *p;
	int n;
	Fontchar *fc;
	Subfont *f;
	int ld;
	Rectangle r;
	Image *i;

	/*
	 * make sure data is word-aligned.  this is true with Plan 9 compilers
	 * but not in general.  the byte order is right because the data is
	 * declared as char*, not ulong*.
	 */
	p = (char*)defontdata;
	n = (ulong)p & 3;
	if(n != 0){
		memmove(p+(4-n), p, sizeofdefont-n);
		p += 4-n;
	}
	ld = atoi(p+0*12);
	r.min.x = atoi(p+1*12);
	r.min.y = atoi(p+2*12);
	r.max.x = atoi(p+3*12);
	r.max.y = atoi(p+4*12);

	i = allocimage(d, r, drawld2chan[ld], 0, 0);
	if(i == 0)
		return 0;

	p += 5*12;
	n = loadimage(i, r, (uchar*)p, (defontdata+sizeofdefont)-(uchar*)p);
	if(n < 0){
		freeimage(i);
		return 0;
	}

	hdr = p+n;
	n = atoi(hdr);
	p = hdr+3*12;
	fc = malloc(sizeof(Fontchar)*(n+1));
	if(fc == 0){
		freeimage(i);
		return 0;
	}
	_unpackinfo(fc, (uchar*)p, n);
	f = allocsubfont("*default*", n, atoi(hdr+12), atoi(hdr+24), fc, i);
	if(f == 0){
		freeimage(i);
		free(fc);
		return 0;
	}
	return f;
}
예제 #8
0
파일: cline.c 프로젝트: 8l/inferno
void
tkcvslinefree(TkCitem *i)
{
	TkCline *l;

	l = TKobj(TkCline, i);
	if(l->stipple)
		freeimage(l->stipple);
	if(l->pen)
		freeimage(l->pen);
}
예제 #9
0
파일: acme.c 프로젝트: UNGLinux/9base
void
iconinit(void)
{
	Rectangle r;
	Image *tmp;

	if(tagcols[BACK] == nil) {
		/* Blue */
		tagcols[BACK] = allocimagemix(display, DPalebluegreen, DWhite);
		tagcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPalegreygreen);
		tagcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DPurpleblue);
		tagcols[TEXT] = display->black;
		tagcols[HTEXT] = display->black;
	
		/* Yellow */
		textcols[BACK] = allocimagemix(display, DPaleyellow, DWhite);
		textcols[HIGH] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DDarkyellow);
		textcols[BORD] = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DYellowgreen);
		textcols[TEXT] = display->black;
		textcols[HTEXT] = display->black;
	}
	
	r = Rect(0, 0, Scrollwid+ButtonBorder, font->height+1);
	if(button && eqrect(r, button->r))
		return;

	if(button){
		freeimage(button);
		freeimage(modbutton);
		freeimage(colbutton);
	}

	button = allocimage(display, r, screen->chan, 0, DNofill);
	draw(button, r, tagcols[BACK], nil, r.min);
	r.max.x -= ButtonBorder;
	border(button, r, ButtonBorder, tagcols[BORD], ZP);

	r = button->r;
	modbutton = allocimage(display, r, screen->chan, 0, DNofill);
	draw(modbutton, r, tagcols[BACK], nil, r.min);
	r.max.x -= ButtonBorder;
	border(modbutton, r, ButtonBorder, tagcols[BORD], ZP);
	r = insetrect(r, ButtonBorder);
	tmp = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DMedblue);
	draw(modbutton, r, tmp, nil, ZP);
	freeimage(tmp);

	r = button->r;
	colbutton = allocimage(display, r, screen->chan, 0, DPurpleblue);

	but2col = allocimage(display, r, screen->chan, 1, 0xAA0000FF);
	but3col = allocimage(display, r, screen->chan, 1, 0x006600FF);
}
예제 #10
0
파일: ctext.c 프로젝트: 8l/inferno
void
tkcvstextfree(TkCitem *i)
{
	TkCtext *t;

	t = TKobj(TkCtext, i);
	if(t->stipple != nil)
		freeimage(t->stipple);
	if(t->pen != nil)
		freeimage(t->pen);
	if(t->text != nil)
		free(t->text);
}
예제 #11
0
파일: canvs.c 프로젝트: 8l/inferno
void
tkfreecanv(Tk *tk)
{
	Display *d;
	int j, locked;
	TkCanvas *c;
	TkName *n, *nn;
	TkCtag *t, *tt;
	TkCitem *i, *next;

	c = TKobj(TkCanvas, tk);
	for(i = c->head; i; i = next) {
		next = i->next;
		tkcvsfreeitem(i);
	}

	if(c->xscroll != nil)
		free(c->xscroll);
	if(c->yscroll != nil)
		free(c->yscroll);

	for(j = 0; j < TkChash; j++) {
		for(n = c->thash[j]; n; n = nn) {
			nn = n->link;
			for(t = n->obj; t; t = tt) {
				tt = t->taglist;
				free(t);
			}
			tkfreebind(n->prop.binds);
			free(n);
		}
	}

	free(c->current);

	if((c->ialloc && c->image != nil) || c->mask != nil) {
		if (c->ialloc && c->image != nil)
			d = c->image->display;
		else
			d = c->mask->display;
		locked = lockdisplay(d);
		if (c->image != nil && c->ialloc)
			freeimage(c->image);
		if (c->mask != nil)
			freeimage(c->mask);
		if(locked)
			unlockdisplay(d);
	}
}
예제 #12
0
파일: win.c 프로젝트: grobe0ba/plan9front
void
resize(void)
{
	Rectangle old, r;
	int dxo, dyo, dxn, dyn;
	Win *w;
	
	old = screen->r;
	dxo = Dx(old);
	dyo = Dy(old);
	if(getwindow(display, Refnone) < 0)
		sysfatal("resize failed: %r");
	dxn = Dx(screen->r);
	dyn = Dy(screen->r);
	freescreen(scr);
	scr = allocscreen(screen, display->white, 0);
	if(scr == nil)
		sysfatal("allocscreen: %r");
	for(w = wlist.next; w != &wlist; w = w->next){
		r = rectsubpt(w->entire, old.min);
		r.min.x = muldiv(r.min.x, dxn, dxo);
		r.max.x = muldiv(r.max.x, dxn, dxo);
		r.min.y = muldiv(r.min.y, dyn, dyo);
		r.max.y = muldiv(r.max.y, dyn, dyo);
		w->entire = rectaddpt(r, screen->r.min);
		w->inner = insetrect(w->entire, BORDSIZ);
		freeimage(w->im);
		w->im = allocwindow(scr, w->entire, Refbackup, 0);
		if(w->im == nil)
			sysfatal("allocwindow: %r");
		draw(w->im, w->inner, w->tab->cols[BACK], nil, ZP);
		border(w->im, w->entire, BORDSIZ, w->tab->cols[w == actw ? BORD : DISB], ZP);
		w->tab->draw(w);
	}
}
예제 #13
0
파일: stats.c 프로젝트: aahud/harvey
void
dropgraph(int which)
{
	Graph *ograph;
	int i, j, n;

	if(which > nelem(menu2str))
		abort();
	/* convert n to index in graph table */
	n = -1;
	for(i=0; i<ngraph; i++)
		if(strcmp(menu2str[which]+Opwid, graph[i].label) == 0){
			n = i;
			break;
		}
	if(n < 0){
		fprint(2, "stats: internal error can't drop graph\n");
		killall("error");
	}
	ograph = graph;
	graph = emalloc(nmach*(ngraph-1)*sizeof(Graph));
	for(i=0; i<nmach; i++){
		for(j=0; j<n; j++)
			graph[i*(ngraph-1)+j] = ograph[i*ngraph+j];
		free(ograph[i*ngraph+j].data);
		freeimage(ograph[i*ngraph+j].overtmp);
		for(j++; j<ngraph; j++)
			graph[i*(ngraph-1)+j-1] = ograph[i*ngraph+j];
	}
	free(ograph);
	ngraph--;
	present[which] = 0;
}
예제 #14
0
파일: page.c 프로젝트: carriercomm/legacy
static
void
freecimage(Cimage *ci)
{
	Cimage *ci1;

	qlock(&cimagelock);
	if(decref(ci) == 0){
		if(ci->i)
			freeimage(ci->i);
		else if(ci->mi)
			freememimage(ci->mi);
		urlfree(ci->url);
		ci1 = cimages;
		if(ci1 == ci)
			cimages = ci->next;
		else{
			while(ci1){
				if(ci1->next == ci){
					ci1->next = ci->next;
					break;
				}
				ci1 = ci1->next;
			}
		}
		free(ci);
	}
	qunlock(&cimagelock);
}
예제 #15
0
void
frclear(Frame *f, int freeall)
{
	if(f->nbox)
		_frdelbox(f, 0, f->nbox-1);
	if(f->box)
		free(f->box);
	if(freeall){
		freeimage(f->tick);
		freeimage(f->tickback);
		f->tick = 0;
		f->tickback = 0;
	}
	f->box = 0;
	f->ticked = 0;
}
예제 #16
0
파일: win.c 프로젝트: grobe0ba/plan9front
void
winclose(Win *w)
{
	if(w->f == nil){
		cmdprint("?\n");
		return;
	}
	if(!decref(w->f)){
		if(w->f->change > 0){
			cmdprint("?\n");
			incref(w->f);
			w->f->change = -1;
			return;
		}
		putfil(w->f);
		w->f = nil;
	}
	freeimage(w->im);
	if(w->f != nil){
		w->wnext->wprev = w->wprev;
		w->wprev->wnext = w->wnext;
	}
	w->next->prev = w->prev;
	w->prev->next = w->next;
	if(w == actw)
		actw = nil;
	if(w == actf)
		actf = nil;
	free(w);
}
예제 #17
0
파일: mnihongo.c 프로젝트: 00001/plan9port
char *pschar(char *s, char *hex, int *wid, int *ht)
{
	Point chpt, spt;
	Image *b;
	uchar rowdata[100];
	char *hp = hex;
	int y, i;

	chpt = stringsize(font, s);		/* bounding box of char */
	*wid = ((chpt.x+7) / 8) * 8;
	*ht = chpt.y;
	/* postscript is backwards to video, so draw white (ones) on black (zeros) */
	b = allocimage(display, Rpt(ZP, chpt), GREY1, 0, DBlack);	/* place to put it */
	spt = string(b, Pt(0,0), display->white, ZP, font, s);	/* put it there */
/* Bprint(&bout, "chpt %P, spt %P, wid,ht %d,%d\n", chpt, spt, *wid, *ht);
/* Bflush(&bout); */
	for (y = 0; y < chpt.y; y++) {	/* read bits a row at a time */
		memset(rowdata, 0, sizeof rowdata);
		unloadimage(b, Rect(0, y, chpt.x, y+1), rowdata, sizeof rowdata);
		for (i = 0; i < spt.x; i += 8) {	/* 8 == byte */
			sprint(hp, "%2.2x", rowdata[i/8]);
			hp += 2;
		}
	}
	*hp = 0;
	freeimage(b);
	return hex;
}
예제 #18
0
void
freefont(Font *f)
{
	int i;
	Cachefont *c;
	Subfont *s;

	if(f == 0)
		return;

	for(i=0; i<f->nsub; i++){
		c = f->sub[i];
		free(c->subfontname);
		free(c->name);
		free(c);
	}
	for(i=0; i<f->nsubf; i++){
		s = f->subf[i].f;
/*		if(s && s!=display->defaultsubfont)*/	/* Plan 9 uses this */
		if(s)
			freesubfont(s);
	}
	freeimage(f->cacheimage);
	free(f->name);
	free(f->cache);
	free(f->subf);
	free(f->sub);
	free(f);
}
예제 #19
0
파일: label.c 프로젝트: 8l/inferno
void
tkfreelabel(Tk *tk)
{
	Image *i;
	int locked;
	Display *d;
	TkLabel *tkl;

	tkl = TKobj(TkLabel, tk);

	if(tkl->text != nil)
		free(tkl->text);
	if(tkl->command != nil)
		free(tkl->command);
	if(tkl->value != nil)
		free(tkl->value);
	if(tkl->variable != nil) {
		tkfreevar(tk->env->top, tkl->variable, tk->flag & Tkswept);
		free(tkl->variable);
	}
	if(tkl->img != nil)
		tkimgput(tkl->img);
	i = tkl->bitmap;
	if(i != nil) {
		d = i->display;
		locked = lockdisplay(d);
		freeimage(i);
		if(locked)
			unlockdisplay(d);
	}
	if(tkl->menu != nil)
		free(tkl->menu);
}
예제 #20
0
파일: page.c 프로젝트: carriercomm/legacy
void
tmpresize(void)
{
	if(tmp)
		freeimage(tmp);

	tmp = eallocimage(display, Rect(0,0,Dx(screen->r),Dy(screen->r)), screen->chan, 0, -1);
}
예제 #21
0
파일: crect.c 프로젝트: 8l/inferno
void
tkcvsrectfree(TkCitem *i)
{
	TkCrect *r;

	r = TKobj(TkCrect, i);
	if(r->stipple)
		freeimage(r->stipple);
}
예제 #22
0
파일: view.c 프로젝트: dancrossnyc/harvey
static void
delayfreeimage(Image *m)
{
	if(m == tofree)
		return;
	if(tofree)
		freeimage(tofree);
	tofree = m;
}
예제 #23
0
void
freesubfont(Subfont *f)
{
	if(f == nil || --f->ref)
		return;
	uninstallsubfont(f);
	free(f->name);
	free(f->info);	/* note: f->info must have been malloc'ed! */
	freeimage(f->bits);
	free(f);
}
예제 #24
0
파일: windw.c 프로젝트: 8l/inferno
void
tkfreectxt(TkCtxt *c)
{
	int locked;
	Display *d;

	if(c == nil)
		return;

	tkextnfreectxt(c);

	d = c->display;
	locked = lockdisplay(d);
	tkfreecolcache(c);
	freeimage(c->i);
	freeimage(c->ia);
	if(locked)
		unlockdisplay(d);
	libqlfree(c->lock);
	free(c);
}
예제 #25
0
파일: main.c 프로젝트: 00001/plan9port
void
freeface(Face *f)
{
	int i;

	if(f->file!=nil && f->bit!=f->file->image)
		freeimage(f->bit);
	freefacefile(f->file);
	for(i=0; i<Nstring; i++)
		free(f->str[i]);
	free(f);
}
예제 #26
0
int main(void)
{
  // make and save
  IMAGE *img=makeimage(500,800);
  saveimage(img,"image3.ppm");
  freeimage(img);
  // read and save
  img=readimage("image3.ppm");
  image2hsv(img);
  saveimage(img,"image3c.ppm");
  return 0;
}
예제 #27
0
파일: VPicEx.cpp 프로젝트: Guokr1991/Hough
//1999-02-18,鲍捷,快速浮雕效果
//只对灰度图像有效
BOOL VPicEx::QuickEmboss()
{
   imgdes *srcimg=GetImgDes();

   imgdes image1; 
   imgdes tmpsrc; 
   int cols, rows, rcode;
   cols = CALC_WIDTH(srcimg);  
   rows = CALC_HEIGHT(srcimg);
   allocimage(&tmpsrc, cols, rows, 8);  
   copyimage(srcimg, &tmpsrc);   
   allocimage(&image1, cols, rows, 8); 
   negative(&tmpsrc, &image1);
   image1.stx = 1;   image1.sty = 1;  
   wtaverage(50, &tmpsrc, &image1, &tmpsrc);
   expandcontrast(100, 155, &tmpsrc, &tmpsrc); 

   rcode = copyimage(&tmpsrc, srcimg); 
   freeimage(&image1);
   freeimage(&tmpsrc); 
   return(rcode == NO_ERROR);
}
예제 #28
0
Image*
allocimagemix(Display *d, ulong color1, ulong color3)
{
	Image *t, *b;
	static Image *qmask;

	if(qmask == nil)
		qmask = allocimage(d, Rect(0,0,1,1), GREY8, 1, 0x3F3F3FFF);
		
	if(d->screenimage->depth <= 8){	/* create a 2×2 texture */
		t = allocimage(d, Rect(0,0,1,1), d->screenimage->chan, 0, color1);
		if(t == nil)
			return nil;

		b = allocimage(d, Rect(0,0,2,2), d->screenimage->chan, 1, color3);
		if(b == nil){
			freeimage(t);
			return nil;
		}

		draw(b, Rect(0,0,1,1), t, nil, ZP);
		freeimage(t);
		return b;
	}else{	/* use a solid color, blended using alpha */
		t = allocimage(d, Rect(0,0,1,1), d->screenimage->chan, 1, color1);
		if(t == nil)
			return nil;

		b = allocimage(d, Rect(0,0,1,1), d->screenimage->chan, 1, color3);
		if(b == nil){
			freeimage(t);
			return nil;
		}

		draw(b, b->r, t, qmask, ZP);
		freeimage(t);
		return b;
	}
}
예제 #29
0
파일: init.c 프로젝트: 99years/plan9
static void
_closedisplay(Display *disp, int isshutdown)
{
	int fd;
	char buf[128];

	if(disp == nil)
		return;
	if(disp == display)
		display = nil;
	if(disp->oldlabel[0]){
		snprint(buf, sizeof buf, "%s/label", disp->windir);
		fd = open(buf, OWRITE);
		if(fd >= 0){
			write(fd, disp->oldlabel, strlen(disp->oldlabel));
			close(fd);
		}
	}

	/*
	 * if we're shutting down, don't free all the resources.
	 * if other procs are getting shot down by notes too,
	 * one might get shot down while holding the malloc lock.
	 * just let the kernel clean things up when we exit.
	 */
	if(isshutdown)
		return;

	free(disp->devdir);
	free(disp->windir);
	freeimage(disp->white);
	freeimage(disp->black);
	close(disp->fd);
	close(disp->ctlfd);
	/* should cause refresh slave to shut down */
	close(disp->reffd);
	qunlock(&disp->qlock);
	free(disp);
}
예제 #30
0
파일: nrotate.c 프로젝트: 99years/plan9
/*
 * Rotate the image 180° by reflecting first
 * along the X axis, and then along the Y axis.
 */
void
rot180(Image *img)
{
	Image *tmp;

	tmp = xallocimage(display, img->r, img->chan, 0, DNofill);
	if(tmp == nil)
		return;

	reverse(img, tmp, Xaxis);
	reverse(img, tmp, Yaxis);

	freeimage(tmp);
}