Changeset 29155


Ignore:
Timestamp:
06/03/14 10:43:28 (9 years ago)
Author:
gost
Message:

[titan] scale jpg without blit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • titan/titan/skin.h

    r29153 r29155  
    15451545        unsigned long color = 0;
    15461546        JSAMPARRAY buffer = NULL;
     1547        unsigned char *tmpbuf = NULL;
     1548        unsigned char *scalebuf = NULL;
    15471549
    15481550        if(cinfo == NULL && buf == NULL) return 1;
     
    16661668                m_unlock(&status.accelfbmutex, 16);
    16671669        }
     1670        else if((scalewidth != 0 || scaleheight != 0) && (scalewidth != width || scaleheight != height) && cinfo != NULL)
     1671        {
     1672                if(halign == CENTER)
     1673                        posx += (mwidth >> 1) - (scalewidth >> 1);
     1674                else if(halign == RIGHT)
     1675                        posx += mwidth - scalewidth;
     1676                if(valign == MIDDLE)
     1677                        posy += (mheight >> 1) - (scaleheight >> 1);
     1678                else if(valign == BOTTOM)
     1679                        posy += mheight - scaleheight;
     1680               
     1681                int i = 0;
     1682                int location = 0;
     1683                tmpbuf = (unsigned char*)malloc(width*height*3);       
     1684                aktline = cinfo->output_scanline;
     1685                while(aktline < height)
     1686                {
     1687                        jpeg_read_scanlines(cinfo, buffer, 1);
     1688                        aktline = cinfo->output_scanline;
     1689                        for(i=0; i<width*3; i++)
     1690                                tmpbuf[location++] = buffer[0][i];
     1691                }
     1692                scalebuf = resize(tmpbuf, width, height, scalewidth, scaleheight, 1, NULL, 1);
     1693               
     1694                aktline = 0;
     1695                while(aktline < scaleheight)
     1696                {
     1697                        py = (posy + aktline) * skinfb->width;
     1698                        aktline1 = aktline * scalewidth * colbytes;
     1699                        for(x = 0; x < width; x++)
     1700                        {
     1701                                px = colbytes * x;
     1702                                red = scalebuf[px + aktline1];
     1703
     1704                                if(colbytes > 2)
     1705                                {
     1706                                        green = scalebuf[aktline1 + (px + 1)];
     1707                                        blue = scalebuf[aktline1 + (px + 2)];
     1708                                        color = (255 << 24) | (red << 16) | (green << 8) | blue;
     1709                                }
     1710                                else
     1711                                        color = (255 << 24) | (red << 16) | (red << 8) | red;
     1712                       
     1713                                drawpixelfast(posx + x, py, color);
     1714                        }
     1715                        aktline++;
     1716                }
     1717                free(scalebuf);
     1718        }       
    16681719        else
    16691720        {
Note: See TracChangeset for help on using the changeset viewer.