Changeset 15278


Ignore:
Timestamp:
04/16/12 00:03:43 (11 years ago)
Author:
nit
Message:

[titan] first step thump creater

Location:
titan/titan
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • titan/titan/defaults.h

    r15272 r15278  
    8585        status.topoffset = getconfigint("fbtopoffset", NULL);
    8686        status.bottomoffset = getconfigint("fbbottomoffset", NULL);
     87        status.createthump = getconfigint("createthump", NULL);
    8788       
    8889        status.bgpic = getskinconfig("bgpic", NULL);
  • titan/titan/skin.h

    r15275 r15278  
    13901390}
    13911391
     1392unsigned char *loadjpg(char *filename, int *width, int *height, int denom)
     1393{
     1394        struct jpeg_decompress_struct cinfo;
     1395        struct jpeg_decompress_struct *ciptr = &cinfo;
     1396        struct jpgerror jerr;
     1397        FILE *fd = NULL;
     1398        unsigned char *buf = NULL;
     1399
     1400        fd = fopen(filename, "rb");
     1401        if(fd == NULL)
     1402        {
     1403                perr("open jpg file %s", filename);
     1404                return NULL;
     1405        }
     1406
     1407        ciptr->err = jpeg_std_error(&jerr.jerr);
     1408        jerr.jerr.error_exit = jpgswerror;
     1409        if(setjmp(jerr.setjmpbuf))
     1410        {
     1411                jpeg_destroy_decompress(ciptr);
     1412                fclose(fd);
     1413                return NULL;
     1414        }
     1415
     1416        jpeg_create_decompress(ciptr);
     1417        jpeg_stdio_src(ciptr, fd);
     1418        jpeg_read_header(ciptr, TRUE);
     1419        ciptr->out_color_space = JCS_RGB;
     1420        ciptr->scale_denom = denom;
     1421
     1422        jpeg_start_decompress(ciptr);
     1423       
     1424        *width = ciptr->output_width;
     1425        *height = ciptr->output_height;
     1426
     1427        if(ciptr->output_components == 3)
     1428        {
     1429                JSAMPLE *lb = (JSAMPLE *)(*ciptr->mem->alloc_small)((j_common_ptr) ciptr, JPOOL_PERMANENT, ciptr->output_width * ciptr->output_components);
     1430                buf = malloc(ciptr->output_height * ciptr->output_width * ciptr->output_components);
     1431                if(buf == NULL)
     1432                {
     1433                        err("no mem");
     1434                        jpeg_destroy_decompress(ciptr);
     1435                        fclose(fd);
     1436                        return NULL;
     1437                }
     1438
     1439                unsigned char *bp = buf;
     1440
     1441                while(ciptr->output_scanline < ciptr->output_height)
     1442                {
     1443                        jpeg_read_scanlines(ciptr, &lb, 1);
     1444                        memcpy(bp, lb, ciptr->output_width * ciptr->output_components);
     1445                        bp += ciptr->output_width * ciptr->output_components;
     1446                }
     1447        }
     1448
     1449        jpeg_finish_decompress(ciptr);
     1450        jpeg_destroy_decompress(ciptr);
     1451        fclose(fd);
     1452        return(buf);
     1453}
     1454
     1455int savejpg(char * filename, int width, int height, unsigned char *buf)
     1456{
     1457        struct jpeg_compress_struct cinfo;
     1458        struct jpeg_error_mgr jerr;
     1459        FILE * outfile;         
     1460        JSAMPROW pointer[1];
     1461        int stride;             
     1462 
     1463        cinfo.err = jpeg_std_error(&jerr);
     1464        jpeg_create_compress(&cinfo);
     1465 
     1466        if((outfile = fopen(filename, "wb")) == NULL)
     1467        {
     1468                perr("jpeg can't open %s", filename);
     1469                return 1;
     1470        }
     1471
     1472        jpeg_stdio_dest(&cinfo, outfile);
     1473 
     1474        cinfo.image_width = width;
     1475        cinfo.image_height = height;
     1476        cinfo.input_components = 3;
     1477        cinfo.in_color_space = JCS_RGB;
     1478        jpeg_set_defaults(&cinfo);
     1479        jpeg_set_quality(&cinfo, 70, TRUE);
     1480        jpeg_start_compress(&cinfo, TRUE);
     1481        stride = width * 3;
     1482
     1483        while (cinfo.next_scanline < cinfo.image_height)
     1484        {
     1485                pointer[0] = & buf[cinfo.next_scanline * stride];
     1486                jpeg_write_scanlines(&cinfo, pointer, 1);
     1487        }
     1488
     1489        jpeg_finish_compress(&cinfo);
     1490        fclose(outfile);
     1491        jpeg_destroy_compress(&cinfo);
     1492        return 0;
     1493}
     1494
    13921495int readjpgsw(const char* filename, int posx, int posy, int mwidth, int mheight, int scalewidth, int scaleheight, int halign, int valign)
    13931496{
     
    19582061{
    19592062//      debug(1000, "in");
    1960         int space = 0, row, pitch, bit, y = 0, x = 0, px = 0, py = 0, pxw = 0, pyh = 0, max = 220, min = 35;
     2063        int space = 0, y = 0, x = 0, py = 0, pxw = 0, pyh = 0, max = 220, min = 35;
    19612064        FT_UInt glyphindex;
    19622065        FT_Vector kerning;
     
    35233626                merkskinfb = NULL;
    35243627        }
    3525         else {
     3628        else
     3629        {
    35263630                if(ostrcmp(getconfig("write_fb_to_jpeg", NULL), "yes") == 0)
    35273631                        write_FB_to_JPEG_file(skinfb->fb, skinfb->width, skinfb->height, "/tmp/fb.jpg", 3);
  • titan/titan/struct.h

    r15271 r15278  
    193193{
    194194        //0-99 for ca module
     195        //101 for thump thread
    195196        int type;
    196197        int flag;
     
    10571058        //background picture for all screens
    10581059        char* bgpic;
     1060        //should thump thread start
     1061        int createthump;
    10591062} status;
    10601063
  • titan/titan/titan.c

    r15272 r15278  
    178178#include "rguid.h"
    179179#include "channelhistroy.h"
     180#include "thump.h"
    180181//#include "cardreader.h"
    181182//#include "sci.h"
     
    751752        //check if box starts from a record
    752753        addtimer(&checkboxstartthread, START, 1000, 1, NULL, NULL, NULL);
    753         //check net
     754        //check kill net (security)
    754755        addtimer(&ckeckkillnetthread, START, 1000, 1, NULL, NULL, NULL);
     756        //thump create thread
     757        if(getconfigint("createthump", NULL) == 1)
     758                addtimer(&thumpthread, START, 1000, 1, NULL, NULL, NULL);
    755759
    756760        //start webserver
Note: See TracChangeset for help on using the changeset viewer.