예제 #1
0
파일: metric.c 프로젝트: Ambrevar/metapixel
void
metric_generate_coeffs_for_subimage (coeffs_union_t *coeffs, bitmap_t *bitmap,
				     int x, int y, int width, int height, metric_t *metric)
{
    if (metric->kind == METRIC_SUBPIXEL)
    {
	bitmap_t *sub_bitmap, *scaled_bitmap;

	sub_bitmap = bitmap_sub(bitmap, x, y, width, height);
	assert(sub_bitmap != 0);

	//bitmap_write(sub_bitmap, "/tmp/sub.png");

	scaled_bitmap = bitmap_scale(sub_bitmap, NUM_SUBPIXEL_ROWS_COLS, NUM_SUBPIXEL_ROWS_COLS, FILTER_MITCHELL);
	assert(scaled_bitmap != 0);

	bitmap_free(sub_bitmap);

	//bitmap_write(scaled_bitmap, "/tmp/scaled.png");

	assert(scaled_bitmap->color == COLOR_RGB_8);
	assert(scaled_bitmap->pixel_stride == NUM_CHANNELS);
	assert(scaled_bitmap->row_stride == NUM_SUBPIXEL_ROWS_COLS * NUM_CHANNELS);

	color_convert_rgb_pixels(coeffs->subpixel.subpixels, scaled_bitmap->data,
				 NUM_SUBPIXELS, metric->color_space);

	bitmap_free(scaled_bitmap);
    }
    else
	assert(0);
}
예제 #2
0
void starcrus_vh_stop(void)
{
	bitmap_free(ship1_vid);
	bitmap_free(ship2_vid);
	bitmap_free(proj1_vid);
	bitmap_free(proj2_vid);
}
예제 #3
0
void victory_vh_stop(void)
{
	/* free dirty maps */
	if (bgdirty)
		free(bgdirty);
	bgdirty = NULL;
	if (chardirty)
		free(chardirty);
	chardirty = NULL;
	if (scandirty)
		free(scandirty);
	scandirty = NULL;

	/* free bitmaps */
	if (bgbitmap)
		bitmap_free(bgbitmap);
	bgbitmap = NULL;
	if (fgbitmap)
		bitmap_free(fgbitmap);
	fgbitmap = NULL;

	/* free bitmapram */
	if (rram)
		free(rram);
	rram = NULL;
	if (gram)
		free(gram);
	gram = NULL;
	if (bram)
		free(bram);
	bram = NULL;
}
예제 #4
0
void toaplan1_vh_stop(void)
{
	rallybik_vh_stop();

	free(toaplan1_buffered_spritesizeram16);
	free(toaplan1_spritesizeram16);
	free(toaplan1_buffered_spriteram16);
	free(toaplan1_spriteram16);
	bitmap_free(tmpbitmap3);
	bitmap_free(tmpbitmap2);
	bitmap_free(tmpbitmap1);
}
예제 #5
0
void TMS9928A_stop (int num_chips) {
	int which;
	/*For each chip*/
	for (which = 0; which < num_chips; which++) {
		free (tms[which].vMem); tms[which].vMem = NULL;
		free (tms[which].dBackMem); tms[which].dBackMem = NULL;
		free (tms[which].DirtyColour); tms[which].DirtyColour = NULL;
		free (tms[which].DirtyName); tms[which].DirtyName = NULL;
		free (tms[which].DirtyPattern); tms[which].DirtyPattern = NULL;
		bitmap_free (tms[which].tmpbmp); tms[which].tmpbmp = NULL;
		bitmap_free (tms[which].tmpsbmp); tms[which].tmpsbmp = NULL;
	}
}
예제 #6
0
파일: work.c 프로젝트: tlvb/vitium
#include "work.h"
#include <stdio.h>

void get_time(imagedata_t *img, const char *fn, logger_t *l) { /*{{{*/
	// this is a hack that is targeted to a
	// specific small set of jpeg images,
	// not expected, or more so, expected to
	// not work with arbitrary files
	log(l, "trying to open \"%s\"\n", fn);
	FILE *fd = fopen(fn, "rb");
	assert(fd);
	char dstr[20];
	fseek(fd, 188, SEEK_SET);
	fread(dstr, sizeof(char), 19, fd);
	fclose(fd);
	dstr[19] = '\0';
	// 2013:12:27 18:20:32
	// 0123456789012345678
	img->time.tm_year = atoi(dstr)-1900;
	img->time.tm_mon = atoi(dstr+5);
	img->time.tm_mday = atoi(dstr+8);
	img->time.tm_hour = atoi(dstr+11);
	img->time.tm_min = atoi(dstr+14);
	img->time.tm_sec = atoi(dstr+17);

	img->stamp = mktime(&img->time);

	log(l, "%s -> %s -> %04d-%02d-%02d %02d:%02d:%02d -> %Ld\n", fn, dstr,
		img->time.tm_year, img->time.tm_mon, img->time.tm_mday,
		img->time.tm_hour, img->time.tm_min, img->time.tm_sec,
		img->stamp
	);
} /*}}}*/
void scalepow2(bitmap_t *out, bitmap_t *in, unsigned int spow) { /*{{{*/
	unsigned int limit = 1<<spow;
	for (size_t ty=0; ty<out->height; ++ty) {
		for (size_t tx=0; tx<out->width; ++tx) {
			size_t tp = tx + ty*out->width;
			unsigned int ys = 0;
			unsigned int cbs = 0;
			unsigned int crs = 0;
			size_t ctr = 0;
			for (size_t y=0; y<limit; ++y) {
				size_t sy = ty*limit + y;
				if (sy >= in->height) { break; }
				for (size_t x=0; x<limit; ++x) {
					size_t sx = tx*limit + x;
					if (sx >= in->width) { break; }
					size_t sp = sx + sy*in->width;
					ys += in->data[sp].x[0];
					cbs += in->data[sp].x[1];
					crs += in->data[sp].x[2];
					++ctr;
				}
			}
			ctr = ctr==0?1:ctr;
			out->data[tp].x[0] = ys/ctr;
			out->data[tp].x[1] = cbs/ctr;
			out->data[tp].x[2] = crs/ctr;
		}
	}
} /*}}}*/
void init_threaddata(threaddata_t *td, const char *ofmt, const char *ifmt, int start, int stop) { /*{{{*/
	log_init(&td->common.l, stdout);
	log(&td->common.l, "- logger created\n");

	td->common.writerstr = calloc(strlen(ofmt)+32, sizeof(char));
	assert(td->common.writerstr != NULL);
	sprintf(td->common.writerstr, "pnmtojpeg -quality=100 > %s", ofmt);
	log(&td->common.l, "- output shape is '%s'\n", td->common.writerstr);

	td->common.readerfmt = ifmt;
	td->common.readerstr = calloc(strlen(ifmt)+16, sizeof(char));
	assert(td->common.readerstr != NULL);
	sprintf(td->common.readerstr, "jpegtopnm < %s", ifmt);
	log(&td->common.l, "- input shape is '%s'\n", td->common.readerstr);

	log(&td->common.l, "- initializing counter\n");
	counter_init(&td->counter, start, stop);

	log(&td->common.l, "- initializing buffer\n");
	buffer_init(&td->buffer, BUFFERSIZE, loader, unloader);

	//font_load_gz(&td->font, "data/sun12x22.psfu");
	font_load_gz(&td->font, "/usr/share/kbd/consolefonts/sun12x22.psfu.gz");
} /*}}}*/
void destroy_threaddata(threaddata_t *td) { /*{{{*/
	buffer_destroy(&td->buffer, &td->common);
	log(&td->common.l, "- destroying counter\n");
	counter_destroy(&td->counter);
	log(&td->common.l, "- destroying logger\n");
	log_destroy(&td->common.l);
	free(td->common.writerstr);
	free(td->common.readerstr);
} /*}}}*/
void *loader(unsigned int index, void* old, void* state, int *status) { /*{{{*/
	ioglobals_t *common = (ioglobals_t*) state;
	char *command = calloc(strlen(common->readerstr)+128, sizeof(char));
	char *fn = calloc(strlen(common->readerfmt)+128, sizeof(char));
	sprintf(command, common->readerstr, index);
	sprintf(fn, common->readerfmt, index);

	imagedata_t *imd = (imagedata_t*)old;
	if (imd == NULL) {
		imd = calloc(sizeof(imagedata_t), 1);
	}
	assert(imd != NULL);

	get_time(imd, fn, &common->l);
	log(&common->l, "reading file %u (%s) with command '%s'\n", index, fn, command);
	free(fn);

	FILE *pfd = popen(command, "r");
	if (!pfd) {
		perror(NULL);
	}
	assert(pfd != NULL);
	int flag = PPM_OK;
	imd->orig = ppm_fread(imd->orig, pfd, &flag);
	pclose(pfd);
	free(command);
	assert(flag == PPM_OK);
	assert(imd->orig != NULL);
	log(&common->l, "wxh: %u x %u\n", imd->orig->width, imd->orig->height);

	unsigned int values[NSC] = {0, 3};
	unsigned int powers[NSC] = {1, 8}; // index zero never used
	for (size_t i=0; i<NSC; ++i) {
		unsigned int additive = powers[i]-1;
		imd->tfsc[i] = bitmap_new(imd->tfsc[i], (imd->orig->width+additive)/powers[i], (imd->orig->height+additive)/powers[i]);
		assert(imd->tfsc[i] != NULL);
		log(&common->l, "index %u: created image %u/%u for colour transform and dimensions %u x %u\n", index, i, NSC, imd->tfsc[i]->width, imd->tfsc[i]->height);
	}
	to_ycbcr(imd->tfsc[0]->data, imd->orig->data, imd->orig->width*imd->orig->height);
	for (size_t i=1; i<NSC; ++i) {
		scalepow2(imd->tfsc[i], imd->tfsc[0], values[i]);
	}
	return imd;
} /*}}}*/
void unloader(void *data, unsigned int index, void *state, bool kill) { /*{{{*/
	ioglobals_t *common = (ioglobals_t*) state;
	if (!kill) {
		log(&common->l, "relinquishing index %u\n", index);
	}
	else {
		imagedata_t *imd = (imagedata_t*) data;
		bitmap_free(imd->orig);
		for (size_t i=0; i<NSC; ++i) {
			bitmap_free(imd->tfsc[i]);
		}
		free(data);
	}
} /*}}}*/
예제 #7
0
파일: gene.c 프로젝트: Ikulagin/transmem
/* =============================================================================
 * gene_free
 * =============================================================================
 */
void
gene_free (gene_t* genePtr)
{
  bitmap_free(genePtr->startBitmapPtr);
  free(genePtr->contents);
  free(genePtr);
}
예제 #8
0
static void video_exit(running_machine *machine)
{
	// free the overlay effect
	if (effect_bitmap != NULL)
		bitmap_free(effect_bitmap);
	effect_bitmap = NULL;

	// possibly kill the debug window
#ifdef MAME_DEBUG
	if (options.mame_debug)
		debugwin_destroy_windows();
#endif

	// free all of our monitor information
	while (win_monitor_list != NULL)
	{
		win_monitor_info *temp = win_monitor_list;
		win_monitor_list = temp->next;
		free(temp);
	}

	// print a final result to the stdout
	if (fps_frames_displayed != 0)
	{
		osd_ticks_t tps = osd_ticks_per_second();
		mame_printf_info("Average FPS: %f (%d frames)\n", (double)tps / (fps_end_time - fps_start_time) * fps_frames_displayed, fps_frames_displayed);
	}
}
예제 #9
0
void save_screen_snapshot_as(void *fp,struct osd_bitmap *bitmap)
{
	if (Machine->drv->video_attributes & VIDEO_TYPE_VECTOR)
		png_write_bitmap(fp,bitmap);
	else
	{
		struct osd_bitmap *copy;
		int sizex, sizey, scalex, scaley;

		sizex = Machine->visible_area.max_x - Machine->visible_area.min_x + 1;
		sizey = Machine->visible_area.max_y - Machine->visible_area.min_y + 1;

		scalex = 1;
		scaley = (Machine->drv->video_attributes & VIDEO_PIXEL_ASPECT_RATIO_1_2) ? 2 : 1;

		copy = bitmap_alloc_depth(sizex * scalex,sizey * scaley,bitmap->depth);

		if (copy)
		{
			copyrozbitmap(copy,bitmap,
					Machine->visible_area.min_x << 16,Machine->visible_area.min_y << 16,
					0x10000 / scalex,0,0,0x10000 / scaley,	/* zoom, no rotation */
					0,	/* no wraparound */
					0,TRANSPARENCY_NONE,0,0);

			png_write_bitmap(fp,copy);
			bitmap_free(copy);
		}
	}
}
예제 #10
0
int main(int argc, const char *argv[]) {
        _cleanup_bitmap_free_ Bitmap *b = NULL;
        Iterator it;
        unsigned n = (unsigned) -1, i = 0;

        b = bitmap_new();
        assert_se(b);

        assert_se(bitmap_ensure_allocated(&b) == 0);
        bitmap_free(b);
        b = NULL;
        assert_se(bitmap_ensure_allocated(&b) == 0);

        assert_se(bitmap_isset(b, 0) == false);
        assert_se(bitmap_isset(b, 1) == false);
        assert_se(bitmap_isset(b, 256) == false);
        assert_se(bitmap_isclear(b) == true);

        assert_se(bitmap_set(b, 0) == 0);
        assert_se(bitmap_isset(b, 0) == true);
        assert_se(bitmap_isclear(b) == false);
        bitmap_unset(b, 0);
        assert_se(bitmap_isset(b, 0) == false);
        assert_se(bitmap_isclear(b) == true);

        assert_se(bitmap_set(b, 1) == 0);
        assert_se(bitmap_isset(b, 1) == true);
        assert_se(bitmap_isclear(b) == false);
        bitmap_unset(b, 1);
        assert_se(bitmap_isset(b, 1) == false);
        assert_se(bitmap_isclear(b) == true);

        assert_se(bitmap_set(b, 256) == 0);
        assert_se(bitmap_isset(b, 256) == true);
        assert_se(bitmap_isclear(b) == false);
        bitmap_unset(b, 256);
        assert_se(bitmap_isset(b, 256) == false);
        assert_se(bitmap_isclear(b) == true);

        assert_se(bitmap_set(b, 32) == 0);
        bitmap_unset(b, 0);
        assert_se(bitmap_isset(b, 32) == true);
        bitmap_unset(b, 32);

        BITMAP_FOREACH(n, NULL, it)
                assert_not_reached("NULL bitmap");

        assert_se(bitmap_set(b, 0) == 0);
        assert_se(bitmap_set(b, 1) == 0);
        assert_se(bitmap_set(b, 256) == 0);

        BITMAP_FOREACH(n, b, it) {
                assert_se(n == i);
                if (i == 0)
                        i = 1;
                else if (i == 1)
                        i = 256;
                else if (i == 256)
                        i = (unsigned) -1;
        }
예제 #11
0
static void vh_close(void)
{
	int i;


	for (i = 0;i < MAX_GFX_ELEMENTS;i++)
	{
		freegfx(Machine->gfx[i]);
		Machine->gfx[i] = 0;
	}
	freegfx(Machine->uifont);
	Machine->uifont = 0;
	osd_close_display();
	if (Machine->scrbitmap)
	{
		bitmap_free(Machine->scrbitmap);
		Machine->scrbitmap = NULL;
	}

	palette_stop();

	if (drv->video_attributes & VIDEO_BUFFERS_SPRITERAM) {
		if (buffered_spriteram) free(buffered_spriteram);
		if (buffered_spriteram_2) free(buffered_spriteram_2);
		buffered_spriteram=NULL;
		buffered_spriteram_2=NULL;
	}
}
예제 #12
0
//
//destroys pool deletion manager threads
//
NVM_KV_Pool_Del_Manager::~NVM_KV_Pool_Del_Manager()
{
    if (m_pools_to_delete)
    {
        bitmap_free(m_pools_to_delete);
    }
}
static void
sfs_block_free(struct sfs_fs *sfs, uint32_t ino) {
    // kprintf("%s\n", __func__);
    assert(sfs_block_inuse(sfs, ino));
    bitmap_free(sfs->freemap, ino);
    sfs->super.unused_blocks ++, sfs->super_dirty = 1;
}
예제 #14
0
void bjtwin_vh_stop(void)
{
	bitmap_free(tmpbitmap);
	free(dirtybuffer);

	dirtybuffer = 0;
	tmpbitmap = 0;
}
예제 #15
0
파일: mac-learning.c 프로젝트: InCNTRE/OFTT
/* Destroys MAC learning table 'ml'. */
void
mac_learning_destroy(struct mac_learning *ml)
{
    if (ml) {
        bitmap_free(ml->flood_vlans);
    }
    free(ml);
}
예제 #16
0
/***************************************************************************

  Stop the video hardware emulation.

***************************************************************************/
void generic_vh_stop(void)
{
	free(dirtybuffer);
	bitmap_free(tmpbitmap);

	dirtybuffer = 0;
	tmpbitmap = 0;
}
예제 #17
0
/***************************************************************************

  Stop the video hardware emulation.

***************************************************************************/
void superqix_vh_stop(void)
{
	free(superqix_bitmapram2);
	free(superqix_bitmapram);
	free(superqix_bitmapram_dirty);
	free(superqix_bitmapram2_dirty);
	bitmap_free(tmpbitmap2);
	free(paletteram);
	generic_vh_stop();
}
예제 #18
0
/**
 * 判断字符串是否包含子串中的所有字符
 * @param char * str 待搜索的字符串
 * @param char * substr 待搜索的字符列表
 * @return 0 or 1
 */
int string_has_chars_of(string str, string substr) {
	bitmap_t * bitmap = bitmap_new(256, 0);
	int i = 0;
	while(str[i] != '\0') {
		bitmap_set(bitmap, str[i]);
		i ++;
	}

	i = 0;
	while(substr[i] != '\0') {
		if(0 == bitmpa_get(bitmap, substr[i])) {
			bitmap_free(bitmap);
			return 0;
		}
		i ++;
	}
	bitmap_free(bitmap);
	return 1;
}
예제 #19
0
int kangaroo_vh_start(void)
{
	if ((tmpbitmap = bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height)) == 0)
		return 1;

	if ((tmpbitmap2 = bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height)) == 0)
	{
		bitmap_free(tmpbitmap);
		return 1;
	}

	if ((videoram = (unsigned char*)malloc(Machine->drv->screen_width*Machine->drv->screen_height)) == 0)
	{
		bitmap_free(tmpbitmap);
		bitmap_free(tmpbitmap2);
	}

	return 0;
}
예제 #20
0
struct bitmap* bitmap_union(struct bitmap *a,struct bitmap *b)
{
	int i;
	if(a->word_alloc>b->word_alloc)
	{
		struct bitmap* result=ewah_malloc(sizeof(struct bitmap));
		eword_t ORresult;
		result->words = ewah_calloc(a->word_alloc*sizeof(eword_t));
		result->word_alloc = a->word_alloc;
		for(i=0;i<b->word_alloc;i++)
		{
			ORresult=a->words[i]|b->words[i];
			memcpy(&result->words[i],&ORresult,sizeof(eword_t));
		}
		for(i=b->word_alloc;i<a->word_alloc;i++)
		{
			memcpy(&result->words[i],&a->words[i],sizeof(eword_t));
		}
		bitmap_free(a);
		bitmap_free(b);
		return result;
	}
	else
	{
		struct bitmap* result=ewah_malloc(sizeof(struct bitmap));
		eword_t ORresult;
		result->words = ewah_calloc(b->word_alloc*sizeof(eword_t));
		result->word_alloc = b->word_alloc;
		for(i=0;i<a->word_alloc;i++)
		{
			ORresult=a->words[i]|b->words[i];
			memcpy(result->words+i,&ORresult,sizeof(eword_t));
		}
		for(i=a->word_alloc;i<b->word_alloc;i++)
		{
			memcpy(&result->words[i],&b->words[i],sizeof(eword_t));
		}
		bitmap_free(a);
		bitmap_free(b);
		return result;
	}
}
예제 #21
0
파일: segments.c 프로젝트: takayuki/al
static void
tester (long geneLength, long segmentLength, long minNumSegment, bool_t doPrint)
{
    gene_t* genePtr;
    segments_t* segmentsPtr;
    random_t* randomPtr;
    bitmap_t* startBitmapPtr;
    long i;
    long j;

    genePtr = gene_alloc(geneLength);
    segmentsPtr = segments_alloc(segmentLength, minNumSegment);
    randomPtr = random_alloc();
    startBitmapPtr = bitmap_alloc(geneLength);

    random_seed(randomPtr, 0);
    gene_create(genePtr, randomPtr);
    random_seed(randomPtr, 0);
    segments_create(segmentsPtr, genePtr, randomPtr);

    assert(segmentsPtr->minNum == minNumSegment);
    assert(vector_getSize(segmentsPtr->contentsPtr) >= minNumSegment);

    if (doPrint) {
        printf("Gene = %s\n", genePtr->contents);
    }

    /* Check that each segment occurs in gene */
    for (i = 0; i < vector_getSize(segmentsPtr->contentsPtr); i++) {
        char *charPtr = strstr(genePtr->contents,
                               (char*)vector_at(segmentsPtr->contentsPtr, i));
        assert(charPtr != NULL);
        j = charPtr - genePtr->contents;
        bitmap_set(startBitmapPtr, j);
        if (doPrint) {
            printf("Segment %li (@%li) = %s\n",
                   i, j, (char*)vector_at(segmentsPtr->contentsPtr, i));
        }
    }

    /* Check that there is complete overlap */
    assert(bitmap_isSet(startBitmapPtr, 0));
    for (i = 0, j = 0; i < geneLength; i++ ) {
        if (bitmap_isSet(startBitmapPtr, i)) {
           assert((i-j-1) < segmentLength);
           j = i;
        }
    }

    gene_free(genePtr);
    segments_free(segmentsPtr);
    random_free(randomPtr);
    bitmap_free(startBitmapPtr);
}
예제 #22
0
/***************************************************************************

  Start the video hardware emulation.

***************************************************************************/
int ccastles_vh_start(void)
{
	if ((tmpbitmap = bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height)) == 0)
		return 1;

	if ((maskbitmap = bitmap_alloc(Machine->drv->screen_width,Machine->drv->screen_height)) == 0)
	{
		bitmap_free(tmpbitmap);
		return 1;
	}

	if ((sprite_bm = bitmap_alloc(16,16)) == 0)
	{
		bitmap_free(maskbitmap);
		bitmap_free(tmpbitmap);
		return 1;
	}

	return 0;
}
예제 #23
0
void volfied_vh_stop (void)
{
	if (video_ram != NULL)
		free(video_ram);

	if (line_dirty != NULL)
		free(line_dirty);

	if (pixel_layer != NULL)
		bitmap_free(pixel_layer);
}
예제 #24
0
static void ui_gfx_exit(running_machine *machine)
{
	/* free the texture */
	if (ui_gfx.texture != NULL)
		render_texture_free(ui_gfx.texture);
	ui_gfx.texture = NULL;

	/* free the bitmap */
	if (ui_gfx.bitmap != NULL)
		bitmap_free(ui_gfx.bitmap);
	ui_gfx.bitmap = NULL;
}
예제 #25
0
int starcrus_vh_start(void)
{
	if ((ship1_vid = bitmap_alloc(16,16)) == 0)
	{
		return 1;
	}

	if ((ship2_vid = bitmap_alloc(16,16)) == 0)
	{
		bitmap_free(ship1_vid);
		return 1;
	}

	if ((proj1_vid = bitmap_alloc(16,16)) == 0)
	{
		bitmap_free(ship1_vid);
		bitmap_free(ship2_vid);
		return 1;
	}

	if ((proj2_vid = bitmap_alloc(16,16)) == 0)
	{
		bitmap_free(ship1_vid);
		bitmap_free(ship2_vid);
		bitmap_free(proj1_vid);
		return 1;
	}

	return 0;
}
예제 #26
0
static void create_bitmap(running_machine *machine, int player)
{
    int x, y;
    char filename[20];
    rgb_t color = crosshair_colors[player];

    /* if we have a bitmap for this player, kill it */
    if (global.bitmap[player] != NULL)
        bitmap_free(global.bitmap[player]);

    if (global.name[player][0] != 0)
    {
        /* look for user specified file */
        sprintf(filename, "%s.png", global.name[player]);
        global.bitmap[player] = render_load_png(OPTION_CROSSHAIRPATH, NULL, filename, NULL, NULL);
    }
    else
    {
        /* look for default cross?.png in crsshair\game dir */
        sprintf(filename, "cross%d.png", player + 1);
        global.bitmap[player] = render_load_png(OPTION_CROSSHAIRPATH, machine->gamedrv->name, filename, NULL, NULL);

        /* look for default cross?.png in crsshair dir */
        if (global.bitmap[player] == NULL)
            global.bitmap[player] = render_load_png(OPTION_CROSSHAIRPATH, NULL, filename, NULL, NULL);
    }

    /* if that didn't work, use the built-in one */
    if (global.bitmap[player] == NULL)
    {
        /* allocate a blank bitmap to start with */
        global.bitmap[player] = bitmap_alloc(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE, BITMAP_FORMAT_ARGB32);
        bitmap_fill(global.bitmap[player], NULL, MAKE_ARGB(0x00,0xff,0xff,0xff));

        /* extract the raw source data to it */
        for (y = 0; y < CROSSHAIR_RAW_SIZE / 2; y++)
        {
            /* assume it is mirrored vertically */
            UINT32 *dest0 = BITMAP_ADDR32(global.bitmap[player], y, 0);
            UINT32 *dest1 = BITMAP_ADDR32(global.bitmap[player], CROSSHAIR_RAW_SIZE - 1 - y, 0);

            /* extract to two rows simultaneously */
            for (x = 0; x < CROSSHAIR_RAW_SIZE; x++)
                if ((crosshair_raw_top[y * CROSSHAIR_RAW_ROWBYTES + x / 8] << (x % 8)) & 0x80)
                    dest0[x] = dest1[x] = MAKE_ARGB(0xff,0x00,0x00,0x00) | color;
        }
    }

    /* create a texture to reference the bitmap */
    global.texture[player] = render_texture_alloc(render_texture_hq_scale, NULL);
    render_texture_set_bitmap(global.texture[player], global.bitmap[player], NULL, TEXFORMAT_ARGB32, NULL);
}
예제 #27
0
파일: mac-learning.c 프로젝트: InCNTRE/OFTT
/* Provides a bitmap of VLANs which have learning disabled, that is, VLANs on
 * which all packets are flooded.  It takes ownership of the bitmap.  Returns
 * true if the set has changed from the previous value. */
bool
mac_learning_set_flood_vlans(struct mac_learning *ml, unsigned long *bitmap)
{
    bool ret = (bitmap == NULL
                ? ml->flood_vlans != NULL
                : (ml->flood_vlans == NULL
                   || !bitmap_equal(bitmap, ml->flood_vlans, 4096)));

    bitmap_free(ml->flood_vlans);
    ml->flood_vlans = bitmap;

    return ret;
}
예제 #28
0
파일: bitmap.c 프로젝트: dugoh/tcb
int bitmap_play(char * filename)
{
    char ch;

    if (fb_init())
    {
	printf ("Unable to init framebuffer device\n");
	return 2;
    }

    fb_pixel * bmp_buffer;

    if ((bmp_buffer = bitmap_load(filename)) == NULL)
    {
	fb_uninit();
	printf ("Error while reading bitmap\n");
	return 1;
    }

    fb_clear_screen(screen);

    bitmap_render(bmp_buffer);

    init_keyboard();

    ch=0;
    while (1)
    {
	if (!kbhit()) 
	{
	    ch = readch();
	    if (ch == KEY_ESC) break;
	    if (ch == KEY_UP && position_y >= JUMP_SIZE) position_y-=JUMP_SIZE;
	    if (ch == KEY_DOWN && fb_yres <= (bmp_info.bi_height-position_y-JUMP_SIZE)) position_y+=JUMP_SIZE;
	    if (ch == KEY_LEFT && position_x >= JUMP_SIZE) position_x-=JUMP_SIZE;
	    if (ch == KEY_RIGHT && fb_xres <= (bmp_info.bi_width-position_x-JUMP_SIZE)) position_x+=JUMP_SIZE;
	    ch = 0;
	    bitmap_render(bmp_buffer);
	}
    }

    close_keyboard();

    fflush(stdin);

    fb_clear_screen(screen);

    bitmap_free(bmp_buffer);
    fb_uninit();
    return 0;
}
예제 #29
0
static void bitmap_list_free(Qcow2BitmapList *bm_list)
{
    Qcow2Bitmap *bm;

    if (bm_list == NULL) {
        return;
    }

    while ((bm = QSIMPLEQ_FIRST(bm_list)) != NULL) {
        QSIMPLEQ_REMOVE_HEAD(bm_list, entry);
        bitmap_free(bm);
    }

    g_free(bm_list);
}
예제 #30
0
static void video_exit(running_machine *machine)
{
	int scrnum;
	int i;

	/* free crosshairs */
	crosshair_free();

	/* stop recording any movie */
	video_movie_end_recording();

	/* free all the graphics elements */
	for (i = 0; i < MAX_GFX_ELEMENTS; i++)
	{
		freegfx(machine->gfx[i]);
		machine->gfx[i] = 0;
	}

	/* free all the textures and bitmaps */
	for (scrnum = 0; scrnum < MAX_SCREENS; scrnum++)
	{
		internal_screen_info *info = &scrinfo[scrnum];
		if (info->texture != NULL)
			render_texture_free(info->texture);
		if (info->bitmap[0] != NULL)
			bitmap_free(info->bitmap[0]);
		if (info->bitmap[1] != NULL)
			bitmap_free(info->bitmap[1]);
	}

	/* free the snapshot target */
	if (snap_target != NULL)
		render_target_free(snap_target);
	if (snap_bitmap != NULL)
		bitmap_free(snap_bitmap);
}