?? jpg.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;
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 + -