⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jpg.c

📁 port of ARM to NOkia 3310 display
💻 C
字号:
Listato 1

while (cinfo.output_scanline < cinfo.output_height) {
	/* jpeg_read_scanlines expects an array of pointers to scanlines.
	 * Here the array is only one element long, but you could ask for
	 * more than one scanline at a time if that's more convenient.
	 */
	unsigned char *imgbuf;
	unsigned char *line_buf = NULL;

	jpeg_read_scanlines(&cinfo, buffer, 1);

	if (imgh > si->height) {
	    if (cinfo.output_scanline < (imgh - si->height) / 2) {
		continue;
	    }
	}

/* Facciamo il test sopra per assicurarci che l'immagine ci sta sullo
schermo, anche se e` piu` alta dello spazio disponibile. */

	line_buf = si->base_buf + (si->scanline * y) + (si->scanline * ystart);

	/* If the image is bigger than the screen, clip it. */
	if (imgw > si->width) {
	    imgcnt = (imgw/2 - si->width/2) * bpp;
	    imgcnt /= 2;
	} else {
	    imgcnt = 0;
	}

/* E anche qua dobbiamo tagliare se l'immagine e` piu` larga dello
schermo. */

	imgbuf = buffer[0];
	imgbuf += imgcnt;

	for (x = xstart; x < si->width; x++)
	{
	    unsigned char *buf = line_buf + (si->bpp * x);

 	    if (x < xstart + imgw) {
		*buf = imgbuf[imgcnt+2];
		*(buf + 1) = imgbuf[imgcnt + 1];
		*(buf + 2) = imgbuf[imgcnt];
		*(buf + 3) = 0;
		imgcnt += 3;
	    }
	}

/* Qua passiamo pixel per pixel e mettiamo li trasferiamo dal nostro
buffer alla memoria video.  Notate che bisogna anche cambiare l'ordine
dei vari pixel rossi, verdi, e blu. */

 	if (y >= imgh + ystart)
	    break;

	/* If we have run out of screen, we still have to finish
	 * hoovering up the data so that libjpeg is happy. */
	if (y >= si->height) {
	    while (cinfo.output_scanline < cinfo.output_height) {
		jpeg_read_scanlines(&cinfo, buffer, 1);
	    }
	    break;
	}

/* Come dice il commento, dobbiamo finire di leggere i dati nel jpeg,
anche se abbiamo finito lo spazio sullo schermo. */

	y++;
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -