static int
draw_frame(uint8_t *src[]) {
  int stride[MP_MAX_PLANES] = {0};

  switch(image_format) {
  case IMGFMT_BGR15:
  case IMGFMT_BGR16:
    stride[0] = src_width*2;
    break;
  case IMGFMT_IYU2:
  case IMGFMT_BGR24:
    stride[0] = src_width*3;
    break;
  case IMGFMT_BGR32:
    stride[0] = src_width*4;
    break;
  }

  sws_scale(sws,src,stride,0,src_height,image,image_stride);

   /* Now 'ASCIInate' the image */
  if (fast)
    aa_fastrender(c, screen_x, screen_y, screen_w + screen_x, screen_h + screen_y );
  else
    aa_render(c, p,screen_x, screen_y, screen_w + screen_x, screen_h + screen_y );

  return 0;
}
示例#2
0
文件: scene7.c 项目: artyfarty/bb-osx
static void ui_display(void)
{
    displayed = 1;
    aa_render(context, params, 0, 0, aa_imgwidth(context), aa_imgheight(context));
    aa_flush(context);

#if 0
    if (numbertype != FORMULA)
	rotate_continue();
#endif
}
示例#3
0
文件: aa_screen.cpp 项目: K0F/FreeJ
void AaScreen::show() {
    int c;
    // make screen_buffer RGBA to grey
    uint8_t *aa_buf = (uint8_t*)aa_image(ascii_context);
    uint32_t *rgb_buf = (uint32_t*) screen_buffer;

    for(c = 0; c < geo.pixelsize; c++)
        aa_buf[c] = .30 * rgba_to_r(rgb_buf[c])
                    + .59 * rgba_to_g(rgb_buf[c])
                    + .11 * rgba_to_b(rgb_buf[c]);


    aa_render(ascii_context, ascii_rndparms, 0, 0, geo.w, geo.h);
    aa_flush(ascii_context);

}
示例#4
0
文件: main.cpp 项目: idaohang/gpsi
int main()
{
  context = aa_autoinit(&aa_defparams);
  if(context == NULL) {
    fprintf(stderr,"Cannot initialize AA-lib. Sorry\n");
    return 1;
  }
  
while(true) {
 aa_puts(context, 0, 10, AA_BOLDFONT, "Azerty is cooler dan qwerty");
aa_putpixel(context,50,50, );
aa_render(context, 50, 50, 100, 100);
aa_flush(context);
}


  aa_close(context);
return 0;
}
static int
draw_slice(uint8_t *src[], int stride[],
	    int w, int h, int x, int y) {

  int dx1 = screen_x + (x * screen_w / src_width);
  int dy1 = screen_y + (y * screen_h / src_height);
  int dx2 = screen_x + ((x+w) * screen_w / src_width);
  int dy2 = screen_y + ((y+h) * screen_h / src_height);

  sws_scale(sws,src,stride,y,h,image,image_stride);

  /* Now 'ASCIInate' the image */
  if (fast)
    aa_fastrender(c, dx1, dy1, dx2, dy2 );
  else
    aa_render(c, p,dx1, dy1, dx2, dy2 );


  return 0;
}
示例#6
0
文件: messager.c 项目: fourks/bb.js
static void toblack1()
{
    int x, y, mul1, mul2 = 0, pos;
    int minpos = 0;
    unsigned char *b1 = bckup, *b2 = bckup1;
    pos = STAGE * (aa_imgheight(context) + aa_imgheight(context)) / (endtime - starttime) - aa_imgheight(context);
    for (y = 0; y < aa_imgheight(context); y++) {
	mul1 = (y - pos);
	if (mul1 < 0)
	    mul1 = 0;
	else
	    mul1 = mul1 * 256 * 4 / aa_imgheight(context);
	if (mul1 > 256)
	    mul1 = 256;
	mul2 = (y - pos - aa_imgheight(context));
	if (mul2 < 0)
	    mul2 = 0;
	else
	    mul2 = mul2 * 256 * 8 / aa_imgheight(context);
	if (mul2 > 256)
	    mul2 = 256;
	if (mul2 == 0)
	    minpos = y;
	mul1 -= mul2;
	for (x = 0; x < aa_imgwidth(context); x++) {
	    aa_putpixel(context, x, y,
			(mul1 * (int) (*b1) + mul2 * (int) (*b2)) / 256);
	    b1++;
	    b2++;
	}
    }
    minpos = pos + 3 * aa_imgheight(context) / 4;
    if (minpos < 0)
	minpos = 0;
    if (minpos > aa_imgheight(context))
	minpos = aa_imgheight(context);
    aa_render(context, params, 0, 0, aa_imgwidth(context), minpos);
    aa_flush(context);
    emscripten_sleep(1);
}
示例#7
0
static GstFlowReturn
gst_aasink_render (GstBaseSink * basesink, GstBuffer * buffer)
{
  GstAASink *aasink;

  aasink = GST_AASINK (basesink);

  GST_DEBUG ("render");

  gst_aasink_scale (aasink, GST_BUFFER_DATA (buffer),   /* src */
      aa_image (aasink->context),       /* dest */
      aasink->width,            /* sw */
      aasink->height,           /* sh */
      aa_imgwidth (aasink->context),    /* dw */
      aa_imgheight (aasink->context));  /* dh */

  aa_render (aasink->context, &aasink->ascii_parms,
      0, 0, aa_imgwidth (aasink->context), aa_imgheight (aasink->context));
  aa_flush (aasink->context);
  aa_getevent (aasink->context, FALSE);

  return GST_FLOW_OK;
}
示例#8
0
static GstFlowReturn
gst_aasink_show_frame (GstVideoSink * videosink, GstBuffer * buffer)
{
  GstAASink *aasink;
  GstVideoFrame frame;

  aasink = GST_AASINK (videosink);

  GST_DEBUG ("show frame");

  if (!gst_video_frame_map (&frame, &aasink->info, buffer, GST_MAP_READ))
    goto invalid_frame;

  gst_aasink_scale (aasink, GST_VIDEO_FRAME_PLANE_DATA (&frame, 0),     /* src */
      aa_image (aasink->context),       /* dest */
      GST_VIDEO_INFO_WIDTH (&aasink->info),     /* sw */
      GST_VIDEO_INFO_HEIGHT (&aasink->info),    /* sh */
      GST_VIDEO_FRAME_PLANE_STRIDE (&frame, 0), /* ss */
      aa_imgwidth (aasink->context),    /* dw */
      aa_imgheight (aasink->context));  /* dh */

  aa_render (aasink->context, &aasink->ascii_parms,
      0, 0, aa_imgwidth (aasink->context), aa_imgheight (aasink->context));
  aa_flush (aasink->context);
  aa_getevent (aasink->context, FALSE);
  gst_video_frame_unmap (&frame);

  return GST_FLOW_OK;

  /* ERRORS */
invalid_frame:
  {
    GST_DEBUG_OBJECT (aasink, "invalid frame");
    return GST_FLOW_ERROR;
  }
}
示例#9
0
文件: scene9.c 项目: artyfarty/bb-osx
static void draw3d(void)
{
    int time = TIME;
    double mul1, mul2, div = (double) (endtime - starttime);
    if (time < starttime - 1)
	time = starttime + 1;
    if (time > endtime)
	time = endtime;
    mul1 = pow((double) (time - starttime) / div, poww), mul2 = 1 - mul1;
    if (mul2 < 0)
	mul1 = 1, mul2 = 0;
    if (mul1 < 0)
	mul2 = 1, mul1 = 0;
    alfa = ((int) IN(salpha, ealpha)) % 360;
    beta = ((int) IN(sbeta, ebeta)) % 360;
    gama = ((int) IN(sgamma, egamma)) % 360;
    centerx = IN(scenterx, ecenterx);
    centery = IN(scentery, ecentery);
    centerz = IN(scenterz, ecenterz);
    zoom = IN(szoom, ezoom);
    disp3d();
    aa_render(context, params, 0, 0, aa_scrwidth(context), aa_scrheight(context));
    aa_flush(context);
}
示例#10
0
文件: aatest.c 项目: dgeelen/tmvp
int main(int argc, char **argv)
{
	aa_context *c;
	int i, y;
	char s[256];
	aa_renderparams *p;
	strcpy(s, "line editor.");
	if (!aa_parseoptions(NULL, NULL, &argc, argv) || argc != 1) {
		printf("%s\n", aa_help);
		exit(1);
	}
	c = aa_autoinit(&aa_defparams);
	if (c == NULL) {
		printf("Can not intialize aalib\n");
		exit(2);
	}
	if (!aa_autoinitkbd(c, 0)) {
		printf("Can not intialize keyboard\n");
		aa_close(c);
		exit(3);
	}
	for (i = 0; i < aa_imgwidth(c); i++)
		for (y = 0; y < aa_imgheight(c); y++)
			aa_putpixel(c, i, y, i + y < 80 ? i : ((i + y) < 100 ? (i + y == 89 ? 150 : 0) : y * 8));
	aa_hidecursor(c);
	aa_fastrender(c, 0, 0, aa_scrwidth(c), aa_scrheight(c));
	aa_printf(c, 0, 0, AA_SPECIAL, "Fast rendering routine %i",1);
	aa_flush(c);
	aa_getkey(c, 1);
	aa_edit(c, 0, 1, 20, s, 256);
	aa_puts(c, 0, 0, AA_SPECIAL, "Key lookup test        ");
	aa_flush(c);
	int ch;
	while ((ch = aa_getevent(c, 1)) != ' ') {
		char s[80];
		sprintf(s, "Key event test-space to exit. c:%i", ch);
		aa_puts(c, 0, 0, AA_SPECIAL, s);
		aa_flush(c);
	}
	if (aa_autoinitmouse(c, AA_MOUSEALLMASK)) {
		int co = 0;
		sprintf(s, "Mouse test-space to exit");
		aa_puts(c, 0, 0, AA_SPECIAL, s);
		aa_flush(c);
		while (aa_getevent(c, 1) != ' ') {
			int x, y, b;
			char s[80];
			co++;
			aa_getmouse(c, &x, &y, &b);
			sprintf(s, "Mouse test-space to exit. x:%i y:%i b:%i event #%i  ", x, y, b, co);
			aa_puts(c, 0, 0, AA_SPECIAL, s);
			aa_flush(c);
		}
		aa_hidemouse(c);
		while (aa_getevent(c, 1) != ' ') {
			int x, y, b;
			char s[80];
			co++;
			aa_getmouse(c, &x, &y, &b);
			sprintf(s, "Hidden mouse test-space to exit. x:%i y:%i b:%i event #%i  ", x, y, b, co);
			aa_puts(c, 0, 0, AA_SPECIAL, s);
			aa_flush(c);
		}
		aa_uninitmouse(c);
	}
	p = aa_getrenderparams();
	for (i = 0; i < AA_DITHERTYPES; i++) {
		p->dither = i;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, aa_dithernames[i]);
		aa_flush(c);
		aa_getkey(c, 1);
	}
	for (i = 0; i < 255; i += 32) {
		p->bright = i;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, "Normal rendering - bright changes");
		aa_flush(c);
		aa_getkey(c, 1);
	}
	p->bright = 0;
	for (i = 0; i < 128; i += 16) {
		p->contrast = i;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, "Normal rendering - contrast changes");
		aa_flush(c);
		aa_getkey(c, 1);
	}
	p->contrast = 0;
	for (i = 0; i < 255; i += 32) {
		p->gamma = 1 + i / 32.0;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, "Normal rendering - gamma changes");
		aa_flush(c);
		aa_getkey(c, 1);
	}
	p->gamma = 1.0;
	for (i = 0; i < 255; i += 32) {
		p->randomval = i;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, "Normal rendering - randomval changes");
		aa_flush(c);
		aa_getkey(c, 1);
	}
	aa_close(c);
	return 0;
}
示例#11
0
文件: bb.c 项目: stroucki/bb
int bb(void)
{
    aa_gotoxy(context, 0, 0);
    introscreen();
    params = aa_getrenderparams();
    aa_render(context, params, 0, 0, 1, 1);
    font = uncompressfont( /*context->params.font */ &aa_font16);
    scenetimer = tl_create_timer();
    srand(time(NULL));
    if (stage != 1)
	finish_stuff = 1;
    do
	switch (stage) {
	default:
	case 1:
	    load_song("bb.s3m");
	    bbupdate();
	    starttime = endtime = TIME;

	    scene1();
	    scene3();
	    if (quitnow)
		goto quit;
	    vezen(&fk1, &fk2, &fk3, &fk4);
	    messager("FILIP KUPSA known as FK, Tingle Notions, Dawn Music\n"
		"birth: June 22 1979, Tabor, Czech Republic, sex: male\n"
		     "\n"
	     "1992 - Changed his piano for 386/mp.com/pc-speaker music\n"
		     "1993 - Got his first Sound Blaster\n"
		     "1995 - Changed his SB for a new GUS technology\n"
		     "1996 - Composed his first great hits\n"
		     "1996 - FAT recomposition made by Windows 95\n"
		     "1997 - Released his musac in BB\n"
		     "\n"
		     "1998 - Got retired\n"
		     "\n"
		     "Contact address: via KT");
	    devezen2();
	    scene4();
	    scene2();
	    if (quitnow)
		goto quit;
	    vezen(&ms1, &ms2, &ms3, &ms4);
	    messager("MOJMIR SVOBODA known as MS, TiTania, MSS, Bill\n"
		     "birth: ??, Tabor, Czech Republic, sex: ? male ?\n"
		     "\n"
		     "1993 - Installed Linux on his 386sx/25 + 40MB HDD\n"
		     "1994 - Removed Linux to make space for Doom\n"
		   "1995 - Reinstalled Linux on his 486Dx4/120 + 850MB\n"
		     "1996 - Removed Linux to make space for Windows 95\n"
		     "\n"
		     "1997 - Removed Windows 95 to make space for aalib\n"
		     "\n"
		     "Contact address: [email protected]");
	    devezen3();
	    scene8();
	    scene6();
	case 2:
	    if (quitnow)
		goto quit;
	    vezen(&kt1, &kt2, &kt3, &kt4);
	    messager("KAMIL TOMAN known as KT, Kato, Whale, Bart\n"
		 "birth: May 19 1979, Tabor, Czech Republic, sex: male\n"
		     "\n"
		     "1993 - Became a linux extremist\n"
		     "1993 - Successful attempt to establish a secret organization\n"
		     "       Commandline Brotherhood\n"
		     "1995 - Action 'koules' - a secret project to train brotherhood\n"
		     "       members - covered under a game design\n"
		     "\n"
		 "1998 - Heading a new wave of command line revolution\n"
		     "\n"
		     "Contact address: [email protected]");
	    bbupdate();
	    starttime = endtime = TIME;
	    devezen1();
	    if (quitnow)
		goto quit;
	    scene7();
	    if (quitnow)
		goto quit;
	    scene5();
	    if (quitnow)
		goto quit;
	    scene10();
	    vezen(&hh1, &hh2, &hh3, &hh4);
	    messager("JAN HUBICKA known as HH, Jahusoft, HuJaSoft, JHS, UNIX, Honza\n"
		  "birth: Apr 1 1978, Tabor, Czech Republic, sex: male\n"
		     "\n"
		     "1991 - Installed underground hackers OS Linux\n"
		     "1995 - Headed Action 'koules'\n"
		     "1996 - Famous troan XaoS to convert all windows instalations\n"
		     "       into Linux\n"
		     "\n"
		     "1998 - Secret plan to make `Text Windows` system to confuse users\n"
		 "2001 - Planning an assassination of dictator Bill G.\n"
		     "\n"
		     "Contact address: [email protected]");
	    devezen4();
	    if (quitnow)
		goto quit;
	    credits();
	    if (quitnow)
		goto quit;
	case 3:
	    if (loopmode)
		break;
	    credits2();
	}
    while (loopmode);
  quit:;
    aa_close(context);
    return (0);
}
示例#12
0
文件: scene9.c 项目: artyfarty/bb-osx
void scene10()
{
    salpha = sbeta = sgamma = scenterx = scentery = scenterz;
    szoom = 0;
    ealpha = ebeta = egamma = ecenterx = ecentery = ecenterz = 0;
    ezoom = 0;
    poww = 1;
    drawptr = NULL;
    patnikconstructor();
    params->gamma = 1;
    centery = -40;
    strobikstart();
    zoom = 3;
    alfa = 90;
    beta = 0;
    gama = 180;
    disp3d();
    aa_render(context, params, 0, 0, aa_scrwidth(context), aa_scrheight(context));
    strobikend();
    bbwait(500000);

    strobikstart();
    alfa = 0;
    disp3d();
    aa_render(context, params, 0, 0, aa_scrwidth(context), aa_scrheight(context));
    strobikend();
    bbwait(500000);

    strobikstart();
    alfa = 180;
    disp3d();
    aa_render(context, params, 0, 0, aa_scrwidth(context), aa_scrheight(context));
    strobikend();
    bbwait(500000);

    strobikstart();
    alfa = 270;
    disp3d();
    aa_render(context, params, 0, 0, aa_scrwidth(context), aa_scrheight(context));
    strobikend();

    salpha = 270;
    sbeta = 0;
    sgamma = 180;
    szoom = 3;
    scentery = -40;
    ealpha = 360 + 90;
    ebeta = 0;
    egamma = 180;
    ezoom = 3;
    ecentery = -40;
    do3d(4 * 1000000);
    poww = 3;
    ezoom = 2;
    ebeta = 90;
    ecenterz = 60;
    ecentery = 50;
    do3d(3 * 1000000);
    poww = 0.4;
    ebeta = 60;
    do3d(0.5 * 1000000);
    poww = 5;
    ebeta = 90;
    do3d(0.5 * 1000000);
    poww = 2;
    ecenterz = 0;
    ecenterx = 60;
    ebeta = 0;
    egamma = 180 * 5;
    ezoom = 0.1;
    do3d(11.5 * 1000000);
    params->gamma = 1;

}
示例#13
0
void draw_juggler(int show_loadavg, aa_context *c, JMLib *j) {
	int color;
	int i;
	struct aajm_loadavg load;

	arm* ap = &(j->ap);
	ball* rhand = &(j->rhand);
	ball* lhand = &(j->lhand);
	hand* handp = &(j->handpoly);

	color = 64;
	// draw head
	aa_drawcircle(c,ap->hx, ap->hy,
			ap->hr, color, -1);

	// draw juggler
	for (i=0;i<5;i++) {
		aa_drawline(c, ap->rx[i], ap->ry[i],
			ap->rx[i+1], ap->ry[i+1], color);
		aa_drawline(c, ap->lx[i], ap->ly[i],
			ap->lx[i+1], ap->ly[i+1], color);
	}

	// hands
	for (i=0; i <= 8; i++) {
		aa_drawline(c, rhand->gx + handp->rx[i],
			rhand->gy + handp->ry[i],
			rhand->gx + handp->rx[i+1],
			rhand->gy + handp->ry[i+1], color);
		aa_drawline(c, lhand->gx + handp->lx[i],
			lhand->gy + handp->ly[i],
			lhand->gx + handp->lx[i+1],
			lhand->gy + handp->ly[i+1], color);
	}
	aa_drawline(c, rhand->gx + handp->rx[9],
		rhand->gy + handp->ry[9],
		rhand->gx + handp->rx[0],
		rhand->gy + handp->ry[0], color);
	aa_drawline(c, lhand->gx + handp->lx[9],
		lhand->gy + handp->ly[9],
		lhand->gx + handp->lx[0],
		lhand->gy + handp->ly[0], color);

	color = 255;
	// draw balls
	int diam = (11*j->dpm/DW);
	for(i=j->numBalls()-1;i>=0;i--) {
		aa_drawcircle(c, j->b[i].gx + diam,
				j->b[i].gy + diam,
				diam, color, color);
	}


	aa_render(c, params, 0, 0,
		aa_imgwidth(c), aa_imgheight(c));

	aa_printf(c, 0, 0, AA_SPECIAL,
		gettext("Site: %s    Style: %s    Balls: %i"),
		j->getSite(), j->getStyle(), j->numBalls());

	if(show_loadavg) {
		loadaverage(&load);
		aa_printf(c, 0, 1, AA_SPECIAL,
			"LoadAvg: %2.2f %2.2f %2.2f",
			load.one, load.five, load.fifteen);
	}
	if(j->getStatus() == ST_PAUSE) {
		aa_puts(c, 1, 3, AA_SPECIAL, gettext("Paused"));
	}
	aa_flush(c);

	memset(c->imagebuffer,0,aa_imgwidth(c)*aa_imgheight(c));
}
status_t
AalibTranslator::DerivedTranslate(BPositionIO *source,
	const translator_info *info, BMessage *ioExtension,
	uint32 outType, BPositionIO *target, int32 baseType)
{
	if(baseType == 1 && outType == AALIB_TEXT_FORMAT) {
		BBitmap *originalbmp, *greyscalebmp;
		BRect bounds;
		
		int imgWidth;
		int imgHeight;
		int imgHalfWidth;
		int imgHalfHeight;
		aa_context *context;
		aa_renderparams *params;
		aa_palette palette;
		struct aa_hardware_params hwparams;
		
		// get the image
		originalbmp = BTranslationUtils::GetBitmap(source);
		if(originalbmp == NULL) {
			return B_ERROR;
		}
		
		// get the image size
		bounds = originalbmp->Bounds();
		imgWidth = bounds.IntegerWidth()+1;
		imgHeight = bounds.IntegerHeight()+1;
		
		// convert the bitmap to greyscale
		greyscalebmp = new BBitmap(bounds, B_GRAY8);
		if(greyscalebmp->ImportBits(originalbmp) != B_OK) {
			return B_ERROR;
		}
		
		// get half the height and width, rounded up
		//   aalib outputs half the height and width of the original
		if(imgWidth%2 == 1)
			imgHalfWidth = (imgWidth+1)/2;
		else
			imgHalfWidth = imgWidth/2;
		
		if(imgHeight%2 == 1)
			imgHalfHeight = (imgHeight+1)/2;
		else
			imgHalfHeight = imgHeight/2;
		
		// use some custom settings
		memcpy(&hwparams, &aa_defparams, sizeof(struct aa_hardware_params));
		hwparams.font = NULL; // default font
		// output is half of original width and height
		hwparams.width = imgHalfWidth;
		hwparams.height = imgHalfHeight;
		
		// new aalib context
		//   use mem_d (memory drive) as we will get the output ourselves
		context = aa_init(&mem_d, &hwparams, NULL);
		if(context == NULL)
			return B_ERROR;
		
		// we can't use memcpy, as the image width
		//   might not be equal to the bytes per row
		/*memcpy(context->imagebuffer,
				greyscalebmp->Bits(),
				imgWidth*imgHeight);*/
		
		// get the location of the bitmap bits, and the bytes per row
		unsigned char *bitsLocation = (unsigned char*)greyscalebmp->Bits();
		int bytesPerRow = greyscalebmp->BytesPerRow();
		for(int y=0; y<imgHeight; y++) { // for each row and column
			for(int x=0; x<imgWidth; x++) {
				// set the pixel
				//   255- is to invert the greyscale image
				aa_putpixel(context, x, y,
								255-(bitsLocation[y*bytesPerRow+x]));
			}
		}
		
		// render the image
		params = aa_getrenderparams();
		aa_render(context, params, 0, 0, imgWidth, imgHeight);
		
		for(int i=0; i<imgHalfHeight; i++) { // for each row
			if(i != 0) { // after first line, write newline
				target->Write("\n",1);
			}
			// output that line
			target->Write(context->textbuffer+i*imgHalfWidth,imgHalfWidth);
		}
		
		aa_close(context);
		free(originalbmp);
		delete greyscalebmp;
		delete originalbmp;
		return B_OK;
	}
	return B_NO_TRANSLATOR;
}