Ejemplo n.º 1
0
int main(int argc, char *argv[]) {
    int j, seg=0, done=0, ch, frames, i, startframe = 1, endframe = 0;
    uint32 temp,len;
    char *filename, *prefilename;

    if(argc < 5) {
        printf("vidconvert USAGE %s [-g gamma][-b brightness][-c contrast] -f frames                         -n prefilename [-s startframe][-e endframe]\n",argv[0]);
        exit(1);
    }

    while ((ch = getopt(argc, argv, "g:b:c:f:n:s:e:")) != EOF) {
        switch(ch) {
        case 'g':
            gamma = atoi(optarg);
            break;
        case 'b':
            bright = atoi(optarg);
            break;
        case 'c':
            contrast = atoi(optarg);
            break;
        case 's':
            startframe = atoi(optarg);
            break;
        case 'e':
            endframe = atoi(optarg);
            break;
        case 'f':
            frames = atoi(optarg);
            break;
        case 'n':
            prefilename = strdup(optarg);
            break;
        default:
            printf("vidconvert USAGE %s [-g gamma][-b brightness][-c contrast] -f frames                         -n prefilename [-s startframe][-e endframe]\n",argv[0]);
        }
    }

    if(!endframe)
        endframe = frames;

    if(strlen(prefilename)>11) {
        printf("invalid prefilename length.\n");
        exit(1);
    }

    filename = malloc(17);

    sprintf(filename, "%s.rvd", prefilename);

    outfp = fopen(filename,"a");

    if(!outfp) {
        printf("couldn't open output stream.\n");
        exit(1);
    }

    maketab(); //generated from gamma contrast and brightness

    for(i = startframe; i<=frames; i++) {

        printf("Opening Frame %d\n", i);

        if(!endframe)
            break;
        endframe--;

        //Reset All variables...

        segbuf = NULL;
        seg = segsize = seglen = segin = yup = xup = ncomp = 0;
        heightDU = widthDU = colsDU = cols8 = maxy = linesize = restinv = ducount = 0;
        buff[0] = buff[1] = buff[2] = NULL;
        coltab = colloc = bmploc = bmpup = NULL;
        dc[0] = dc[1] = dc[2] = 0;

        reset();

        //take into account for the zeros with greater frame totals
        if(frames < 100) {
            if(i<10)
                sprintf(filename, "%s 0%d.jpg", prefilename, i);
            else
                sprintf(filename, "%s %d.jpg", prefilename,i);
        } else {
            if(i<10)
                sprintf(filename, "%s 00%d.jpg", prefilename, i);
            else if(i<100)
                sprintf(filename, "%s 0%d.jpg", prefilename, i);
            else
                sprintf(filename, "%s %d.jpg", prefilename,i);
        }

        filefd = open(filename, O_READ);
        if (filefd == -1) {
            printf("Unable to open file %s... re-using previous frame.\n", filename);
            j=1;
            while(i-j > 0) {
                if(frames < 500) {
                    if(i<10)
                        sprintf(filename, "%s 0%d.jpg", prefilename, i-j);
                    else
                        sprintf(filename, "%s %d.jpg", prefilename,i-j);
                } else {
                    if(i<10)
                        sprintf(filename, "%s 00%d.jpg", prefilename, i-j);
                    else if(i<100)
                        sprintf(filename, "%s 0%d.jpg", prefilename, i-j);
                    else
                        sprintf(filename, "%s %d.jpg", prefilename,i-j);
                }
                filefd = open(filename, O_READ);
                if(filefd == -1)
                    j++;
                else
                    break;
            }
            if(i-j < 1)
                continue;
        }

        seg = loadseg();

        if (seg == 0xd8)
            printf("It's a jpeg!\n");
        else {
            printf("Image file %s, is not a JPEG '%d'... skipping it.\n", filename, seg);
            exit(1);
        }

        while(seg != 0xda) {
            seg = loadseg();

            if(!seg)
                goto skiptonext;

            switch(seg) {
            case 0xdb:
                if(!segDQT())
                    goto skiptonext;
                break;
            case 0xc4:
                if(!segDHT())
                    goto skiptonext;
                break;
            case 0xda:
                segSOS();
                break;
            case 0xc0:
                segSOF();
                break;
            case 0xdd:
                segDRI();
                break;
            }
        }

        bmpwidth  = round8(width);
        bmpheight = round8(height);
        imgsize   = ((bmpheight*bmpwidth)/8) + ((bmpwidth*bmpheight)/64);
        width8    = bmpwidth/8;
        temp      = (uint32) width8 * bmpheight;
        len       = temp/8+temp;
        bmpup     = bmploc = calloc(len, 1);
        colloc    = bmploc+temp;

        while (!done) {
            imagedata();
            render();
            yup += heightDU;
            if (yup >= height) {
                done=1;
                printf("Finished rendering frame %d\n", i);
                rle();
                printf("Finished RLE encoding frame %d\n", i);
            }
        }
        done = 0;
skiptonext:
        close(filefd);
    }
    fclose(outfp);
    return(1);
}
Ejemplo n.º 2
0
void DreamGenContext::startloading(const Room *room) {
	data.byte(kCombatcount) = 0;
	data.byte(kRoomssample) = room->roomsSample;
	data.byte(kMapx) = room->mapX;
	data.byte(kMapy) = room->mapY;
	data.byte(kLiftflag) = room->liftFlag;
	data.byte(kManspath) = room->b21;
	data.byte(kDestination) = room->b21;
	data.byte(kFinaldest) = room->b21;
	data.byte(kFacing) = room->b22;
	data.byte(kTurntoface) = room->b22;
	data.byte(kCounttoopen) = room->countToOpen;
	data.byte(kLiftpath) = room->liftPath;
	data.byte(kDoorpath) = room->doorPath;
	data.byte(kLastweapon) = -1;
	al = room->b27;
	push(ax);
	al = room->b31;
	ah = data.byte(kReallocation);
	data.byte(kReallocation) = al;
	dx = bx;
	Common::String name = getFilename(*this);
	engine->openFile(name);
	cs.word(kHandle) = 1; //only one handle
	flags._c = false;
	readheader();
	allocateload();
	ds = ax;
	data.word(kBackdrop) = ax;
	dx = (0);
	loadseg();
	ds = data.word(kWorkspace);
	dx = (0);
	cx = 132*66;
	al = 0;
	fillspace();
	loadseg();
	sortoutmap();
	allocateload();
	data.word(kSetframes) = ax;
	ds = ax;
	dx = (0);
	loadseg();
	ds = data.word(kSetdat);
	dx = 0;
	cx = (64*128);
	al = 255;
	fillspace();
	loadseg();
	allocateload();
	data.word(kReel1) = ax;
	ds = ax;
	dx = 0;
	loadseg();
	allocateload();
	data.word(kReel2) = ax;
	ds = ax;
	dx = 0;
	loadseg();
	allocateload();
	data.word(kReel3) = ax;
	ds = ax;
	dx = 0;
	loadseg();
	allocateload();
	data.word(kReels) = ax;
	ds = ax;
	dx = 0;
	loadseg();
	allocateload();
	data.word(kPeople) = ax;
	ds = ax;
	dx = 0;
	loadseg();
	allocateload();
	data.word(kSetdesc) = ax;
	ds = ax;
	dx = 0;
	loadseg();
	allocateload();
	data.word(kBlockdesc) = ax;
	ds = ax;
	dx = 0;
	loadseg();
	allocateload();
	data.word(kRoomdesc) = ax;
	ds = ax;
	dx = 0;
	loadseg();
	allocateload();
	data.word(kFreeframes) = ax;
	ds = ax;
	dx = 0;
	loadseg();
	ds = data.word(kFreedat);
	dx = 0;
	cx = (16*80);
	al = 255;
	fillspace();
	loadseg();
	allocateload();
	data.word(kFreedesc) = ax;
	ds = ax;
	dx = (0);
	loadseg();
	closefile();
	findroominloc();
	deletetaken();
	setallchanges();
	autoappear();
	al = data.byte(kNewlocation);
	getroomdata();
	data.byte(kLastweapon) = -1;
	data.byte(kMandead) = 0;
	data.word(kLookcounter) = 160;
	data.byte(kNewlocation) = 255;
	data.byte(kLinepointer) = 254;
	ax = pop();
	if (al != 255) {
		data.byte(kManspath) = al;
		push(bx);
		autosetwalk();
		bx = pop();
	}
	findxyfrompath();
}
Ejemplo n.º 3
0
int main(int argc, char *argv[]) {
	int RcvId, xsize,ysize,minxsize,minysize;
	void *msg;
	void *App, *window, *bmp, *scr, *view;
	int seg=0,done=0,ch;
	uint32 temp,len;
        JMeta * metadata = malloc(sizeof(JMeta));	

	while ((ch = getopt(argc, argv, "g:b:c:")) != EOF) {
		switch(ch) {
		case 'g': 
			gamma = atoi(optarg);
			break;
		case 'b':
			bright = atoi(optarg);
			break;
		case 'c':
			contrast = atoi(optarg);
			break;
		}
			
	}
	if (argc-optind < 1)
		exit(1);
	filefd = open(argv[optind], O_READ);
	if (filefd == -1) {
		perror(argv[optind]);
		exit(1);
	}
	maketab();
	chan = makeChan();
	seg = loadseg();
	if (seg == 0xd8) {
		printf("It's a jpeg!\n");
	} else abort("Not a jpeg!\n");
	while(seg != 0xda) {
		seg = loadseg();
/*		printf("It's %2x, size %4x\n", seg, seglen); */
		switch(seg) {
			case 0xdb:
				segDQT();
				break;
			case 0xc4:
				segDHT();
				break;
			case 0xda:
				segSOS();
				break;
			case 0xc0:
				segSOF();
				break;
			case 0xdd:
				segDRI();
				break;
			default:
				printf("Unknown segment %d\n", seg);
				break;
		}
	}
	bmpwidth = round8(width);
	bmpheight = round8(height);

        metadata->launchpath = strdup(fpathname(argv[0],getappdir(),1));
        metadata->title = "Jpeg viewer";
        metadata->icon = app_icon;
        metadata->showicon = 1;
        metadata->parentreg = -1;

	App = JAppInit(NULL, chan);
	window = JWndInit(NULL, "Jpeg viewer by J. Maginnis and S. Judd", JWndF_Resizable,metadata);
        ((JCnt *)window)->Orient = JCntF_TopBottom;

        xsize = bmpwidth;
        ysize = bmpheight;

        if(xsize > 296)
          xsize = 296;
        else if(xsize < 64)
          xsize = 64;

        if(ysize > 160)
          ysize = 160;
        else if(ysize < 24)
          ysize = 24;

        if(xsize > 64)
          minxsize = 64;
        else
          minxsize = xsize;

        minysize = 24;

        JWSetBounds(window,0,0,xsize,ysize+16);
        JWSetMin(window,minxsize,minysize);
        JWSetMax(window,xsize+8,ysize+24);
        JAppSetMain(App,window);

	width8 = bmpwidth/8;
	temp = (uint32) width8 * bmpheight;
	len = temp/8+temp;
	bmpup = bmploc = calloc(len, 1);
	colloc = bmploc+temp;
	//printf("%dx%d, %lx bytes, %lx,%lx,%lx\n", bmpwidth, bmpheight, len, bmpup, colloc, bmpup+len);

	bmp = JBmpInit(NULL, bmpwidth, bmpheight, bmploc);
	view = JViewWinInit(NULL, bmp);
	scr = JScrInit(NULL, view, JScrF_VNotEnd|JScrF_HNotEnd);
        JWSetMin(scr,8,8);

	JCntAdd(window, scr);
       
        JWndSetProp(window);
	JWinShow(window);

    retexit(1);

	while(1) {
		while (!done && !chkRecv(chan)) {
			imagedata();
			render();
			JWReDraw(bmp);
			yup += heightDU;
			if (yup >= height) {
				FILE *fp;
				done=1;
				printf("Finished render\n");
/*				fp = fopen("bmpout","wb");
				if (fp) {
					fwrite(bmploc, 320*25+1000, 1, fp);
					fclose(fp);
				} */
			}
		}
		RcvId = recvMsg(chan, &msg);
		switch (* (int *)msg) {
		case WIN_EventRecv:
			JAppDrain(App);
			break;			
		}
		replyMsg(RcvId,0);
	}

	return 1;
}