示例#1
0
static void
draw_lock_icon (cairo_t *cr,
                int size)
{
        cairo_translate (cr, (BOX_WIDTH(size) + LINE_SIZE(size)) / 2, (CURVE_HEIGHT(size) - BOX_HEIGHT(size)) / 2);

        cairo_set_line_width (cr, LINE_SIZE(size));
        cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);

        cairo_move_to (cr, - BOX_WIDTH(size) / 2, 0);
        cairo_line_to (cr, BOX_WIDTH(size) / 2, 0);
        cairo_line_to (cr, BOX_WIDTH(size) / 2, BOX_HEIGHT(size));
        cairo_line_to (cr, - BOX_WIDTH(size) / 2, BOX_HEIGHT(size));
        cairo_close_path (cr);

        cairo_fill_preserve (cr);

        cairo_move_to (cr, -CURVE_WIDTH(size) / 2, 0);
        cairo_line_to (cr, - CURVE_WIDTH(size) / 2, - CURVE_HEIGHT(size) + CURVE_RADIUS(size));
        cairo_curve_to (cr, - CURVE_WIDTH(size) / 2, - CURVE_HEIGHT(size) + CURVE_BEZIER(size),
                            - CURVE_WIDTH(size) / 2 + CURVE_BEZIER(size), - CURVE_HEIGHT(size),
                            - CURVE_WIDTH(size) / 2 + CURVE_RADIUS(size), - CURVE_HEIGHT(size));
        cairo_line_to (cr, CURVE_WIDTH(size) / 2 - CURVE_RADIUS(size), - CURVE_HEIGHT(size));
        cairo_curve_to (cr, CURVE_WIDTH(size) / 2 - CURVE_BEZIER(size), - CURVE_HEIGHT(size),
                            CURVE_WIDTH(size) / 2, - CURVE_HEIGHT(size) + CURVE_BEZIER(size),
                            CURVE_WIDTH(size) / 2, - CURVE_HEIGHT(size) + CURVE_RADIUS(size));
        cairo_line_to (cr, CURVE_WIDTH(size) / 2, 0);

        cairo_stroke (cr);
}
示例#2
0
文件: imgtype.c 项目: dk/Prima
static void
ic_Byte_convert( Handle self, Byte * dstData, PRGBColor dstPal, int dstType, int * dstPalSize, Bool palSize_only, Bool inplace)
{
	int new_data_size = LINE_SIZE(var->w, 8) * var->h;
	Byte * new_data;
	RGBColor dummy_pal[256];
	int dummy_pal_size = 0;

	if ( !inplace) {
		new_data = allocb( new_data_size);
		if ( !new_data) {
			croak("Not enough memory:%d bytes", new_data_size);
			return;
		}
		memset( new_data, 0, new_data_size);
	} else
		new_data = var-> data;
	ic_type_convert( self, new_data, dummy_pal, imByte, &dummy_pal_size, false);
	if ( !inplace) {
		free( var-> data);
		var-> data = new_data;
	}
	var-> type = imByte;
	var-> dataSize = new_data_size;
	var-> lineSize = new_data_size / var-> h;
	memcpy( var-> palette, std256gray_palette, sizeof(std256gray_palette));
	var-> palSize = 256;
	ic_type_convert( self, dstData, dstPal, dstType, dstPalSize, palSize_only);
}
示例#3
0
PUBLIC HText *	LMHText_new (
	HTRequest * request,
	HTParentAnchor * anchor,
	HTStream *outstrm)
{
    HTLine * line;
    HText * self;
    if ((self = (HText  *) HT_CALLOC(1, sizeof(*self))) == NULL)
/*        HT_OUTOFMEM("HText"); */
	return self;
    
    self->pLm = Context_getLineMode(request);
    if (!loaded_texts) loaded_texts = HTList_new();
    HTList_addObject(loaded_texts, self);
    if (HTList_count(loaded_texts) >= LOADED_LIMIT) {
        HTTRACE(CACHE_TRACE, "MemoryCache. Freeing off cached doc.\n"); 
        HText_free((HText *)HTList_removeFirstObject(loaded_texts));
    }
    
    if ((line = self->last_line = (HTLine *) HT_MALLOC(LINE_SIZE(MAX_LINE))) == NULL)
	HT_OUTOFMEM("HText_New");
    line->next = line->prev = line;
    line->offset = line->size = 0;
    self->lines = self->chars = 0;
    self->title = 0;
    self->first_anchor = self->last_anchor = self->current_anchor = 0;
    self->style = &default_style;
    self->top_of_screen = 0;
    self->node_anchor = anchor;
    self->last_anchor_number = 0;	/* Numbering of them for references */
    self->stale = YES;
    
    self->target = NULL;
    
    HTAnchor_setDocument(anchor, (void *) self);

    clear_screen();
    HTMainText = self;
    HTMainAnchor = anchor;
    self->display_on_the_fly = DISPLAY_LINES;
    self->all_pages = NO;	/* One page at a time on the fly */
    
    if (!space_string) {	/* Make a blank line */
        char *p;
	if ((space_string = (char  *) HT_MALLOC(HTScreenWidth+1)) == NULL)
	    HT_OUTOFMEM("HText_New");
        for (p=space_string; p<space_string+HTScreenWidth; p++) 
            *p = ' '; 		/* Used for printfs later */
        space_string[HTScreenWidth] = '\0'; 
    }
    
    return self;
}
示例#4
0
Bool
img_mirror_raw( int type, int w, int h, Byte * data, Bool vertically)
{
	int y;
	int ls = LINE_SIZE(w, type);
	register Byte swap;

	if ( vertically ) {
		Byte * src = data, *dst = data + ( h - 1 ) * ls, *p, *q;
		h /= 2;
		for ( y = 0; y < h; y++, src += ls, dst -= ls ) {
			register int t = ls;
			p = src;
			q = dst;
			while ( t-- ) {
				swap = *q;
				*(q++) = *p;
				*(p++) = swap;
			}
		}
	} else {
		int x, pixel_size = (type & imBPP) / 8, last_pixel = (w - 1) * pixel_size, w2 = w / 2;
		switch (type & imBPP) {
		case 1:
		case 4:
			 return false;
		case 8:
			for ( y = 0; y < h; y++, data += ls ) {
				Byte *p = data, *q = data + last_pixel;
				register int t = w2;
				while ( t-- ) {
					swap = *q;
					*(q--) = *p;
					*(p++) = swap;
				}
			}
			break;
		default:
			for ( y = 0; y < h; y++, data += ls ) {
				Byte *p = data, *q = data + last_pixel;
				for ( x = 0; x < w2; x++, q -= pixel_size * 2) {
					register int t = pixel_size;
					while (t--) {
						swap = *q;
						*(q++) = *p;
						*(p++) = swap;
					}
				}
			}
		} 	    
	}
	return true;
}
示例#5
0
文件: main.c 项目: nil0x42/duplicut
/** Rewrite file without zero-tagged lines, and update file size.
 */
static void     remove_duplicates(void)
{
    t_chunk     file_chunk;
    t_line      line;
    size_t      line_size;
    char        *dst;

    file_chunk.ptr = g_file->addr;
    file_chunk.endptr = g_file->addr + g_file->info.st_size;

    dst = file_chunk.ptr;
    while (get_next_line(&line, &file_chunk))
    {
        line_size = LINE_SIZE(line);
        memcpy(dst, LINE_ADDR(line), line_size);
        dst += line_size;
        if (dst != file_chunk.endptr)
            *dst++ = '\n';
    }

    /* update file size */
    g_file->info.st_size = dst - g_file->addr;
}
示例#6
0
PRIVATE void split_line (HText * text, int split)
{
    HTStyle * style = text->style;
    int spare;
    int indent = (int) (text->in_line_1 ? text->style->indent1st
			: text->style->leftIndent);

/*	Make new line
*/
    HTLine * previous = text->last_line;
    HTLine * line;
    if ((line = (HTLine  *) HT_MALLOC(LINE_SIZE(MAX_LINE))) == NULL)
        HT_OUTOFMEM("split_line");

    text->lines++;
    
    previous->next->prev = line;
    line->prev = previous;
    line->next = previous->next;
    previous->next = line;
    text->last_line = line;
    line->size = 0;
    line->offset = 0;

/*	Split at required point
*/    
    if (split) {	/* Delete space at "split" splitting line */
	char * p;
	previous->data[previous->size] = 0;
	for (p = &previous->data[split]; *p; p++)
	    if (*p != ' ') break;
	strcpy(line->data, p);
	line->size = strlen(line->data);
	previous->size = split;
    }
    
    while ((previous->size > 0) &&
	   (previous->data[previous->size-1] == ' '))	/* Strip trailers */
        previous->size--;

    if ((previous = (HTLine *)
	 HT_REALLOC(previous, LINE_SIZE(previous->size)))==NULL)
	HT_OUTOFMEM("split_line");
    previous->prev->next = previous;	/* Link in new line */
    previous->next->prev = previous;	/* Could be same node of course */

/*	Terminate finished line for printing
*/
    previous->data[previous->size] = 0;

/*	Align left, right or center
*/

    spare =  (int) (HTScreenWidth - style->rightIndent + style->leftIndent -
		    previous->size);		     /* @@ first line indent */
		
    switch (style->alignment) {
	case HT_CENTER :
	    previous->offset = previous->offset + indent + spare/2;
	    break;
	case HT_RIGHT :
	    previous->offset = previous->offset + indent + spare;
	    break;
	case HT_LEFT :
	case HT_JUSTIFY :		/* Not implemented */
	default:
	    previous->offset = previous->offset + indent;
	    break;
    } /* switch */

    text->chars = text->chars + previous->size + 1;	/* 1 for the line */
    text->in_line_1 = NO;		/* unless caller sets it otherwise */
    
/*	If displaying as we go, output it:
*/
    if (text->display_on_the_fly) {
        if (text->display_on_the_fly == DISPLAY_LINES) { /* First line */
	    if (previous->size == 0) {
	        text->top_of_screen++;	/* Scroll white space off top */
		return;
	    }
	    if (HTAnchor_title(text->node_anchor)) { /* Title exists */
	        display_title(text);
	        text->display_on_the_fly--;
	    }
	}
	display_line(text, previous);
	text->display_on_the_fly--;
	
	/* Loop to top of next page? */
	if (!text->display_on_the_fly && text->all_pages) {
	    PUTS("\f\n"); /* Form feed on its own line a la rfc1111 */
	    text->display_on_the_fly = DISPLAY_LINES;
	}
    }
} /* split_line */