Changeset 171


Ignore:
Timestamp:
Dec 28, 2006, 7:16:43 PM (15 years ago)
Author:
Eugene Romanenko
Message:

to rediuce size of spool data: reduce number of colors when multiple pages printed as image

Location:
trunk/Lucide/SOURCE
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Lucide/SOURCE/gui/docViewer.cpp

    r166 r171  
    5252#include "messages.h"
    5353
     54
     55// ASYNCH_RENDER_ENABLE, normally must be defined
     56#define ASYNCH_RENDER_ENABLE
    5457
    5558typedef LuDocument_LuRectSequence    *PLuRectSequence;
     
    220223        }
    221224        else {
     225#ifdef ASYNCH_RENDER_ENABLE
    222226            enableAsynchDraw = doc->isAsynchRenderingSupported( ev );
     227#else
     228            enableAsynchDraw = false;
     229#endif
    223230        }
    224231        goToPage( 0 );
  • trunk/Lucide/SOURCE/gui/makefile

    r156 r171  
    3737       fontsInfoDlg.obj docInfoDlg.obj findDlg.obj progressDlg.obj \
    3838       aboutDlg.obj settingsDlg.obj lusettings.obj printDlg.obj \
    39        print.obj stbrowser.obj pipemon.obj lucidethumbs.obj
     39       print.obj stbrowser.obj pipemon.obj lucidethumbs.obj neuquant.obj
    4040
    4141lucide.dll: $(OBJS) lucide.res
     
    7171file $(OBJDIR)\pipemon.obj
    7272file $(OBJDIR)\lucidethumbs.obj
     73file $(OBJDIR)\neuquant.obj
    7374name $(EXEDIR)\lucide
    7475lib ..\plugins\ludoc\ludoc
     
    132133wwbtn.obj:          wwbtn.c
    133134stbrowser.obj:      stbrowser.c
     135neuquant.obj:       neuquant.cpp
    134136lcd.obj:            lcd.c               makefile
    135137
  • trunk/Lucide/SOURCE/gui/print.cpp

    r166 r171  
    5454#include "luutils.h"
    5555#include "messages.h"
     56#include "neuquant.h"
    5657
    5758
     
    6465#define HIGH_IMAGE_ZOOM     3.0
    6566#define PS_PRINT_BUF_SIZE   32768
     67
     68void rgb_to_pal8( LuPixbuf *dst, LuPixbuf *src, int width, int height, BYTE *p_pal );
    6669
    6770
     
    7679    private:
    7780        bool queryCurrentForm( HAB lhab, PHCINFO pcurForm );
    78         void printPagePm( long page, HPS hpsPrinter, PHCINFO pcurForm );
     81        void printPagePm( long page, HPS hpsPrinter, PHCINFO pcurForm, bool reduceColors );
    7982        bool doPmPrint( HAB lhab );
    8083        bool doPsPrint( HAB lhab );
     
    176179        delete buf;
    177180
    178         printPagePm( pg - 1, hpsPrinter, &curForm );
     181        printPagePm( pg - 1, hpsPrinter, &curForm, ( totalpages > 1 ) );
    179182
    180183        if ( pg != psetup->pgto ) {
     
    201204
    202205
    203 void LucidePrinting::printPagePm( long page, HPS hpsPrinter, PHCINFO pcurForm )
     206void LucidePrinting::printPagePm( long page, HPS hpsPrinter,
     207                                  PHCINFO pcurForm, bool reduceColors )
    204208{
    205209    long bpp = doc->getBpp( ev );
     
    264268
    265269        LONG lRop = ROP_SRCCOPY;
    266         BITMAPINFO2 pbmi;
    267         pbmi.cbFix = 16L;
    268         pbmi.cx = rclx;
    269         pbmi.cy = rcly;
    270         pbmi.cPlanes = 1;
    271         pbmi.cBitCount = bpp * 8;
    272         GpiDrawBits( hpsPrinter, pixbuf->getDataPtr( ev ), &pbmi, 4L,
    273                      aptlPoints, lRop, BBO_IGNORE );
     270        if ( reduceColors )
     271        {
     272            LONG bhsz = sizeof( BITMAPINFOHEADER2 ) + ( sizeof( RGB2 ) * 256 );
     273            BITMAPINFO2 *pbmi = (BITMAPINFO2 *)malloc( bhsz );
     274            memset( pbmi, 0, bhsz );
     275            pbmi->cbFix = sizeof( BITMAPINFOHEADER2 );
     276            pbmi->cx = rclx;
     277            pbmi->cy = rcly;
     278            pbmi->cPlanes = 1;
     279            pbmi->cBitCount = 8;
     280            pbmi->ulCompression = BCA_UNCOMP;
     281            pbmi->cbImage = 0;
     282            pbmi->cxResolution = 0;
     283            pbmi->cyResolution = 0;
     284            pbmi->cclrUsed = 0;
     285            pbmi->cclrImportant = 0;
     286            pbmi->usUnits = BRU_METRIC;
     287            pbmi->usReserved = 0;
     288            pbmi->usRecording = BRA_BOTTOMUP;
     289            pbmi->usRendering = BRH_NOTHALFTONED;
     290            pbmi->cSize1 = 0;
     291            pbmi->cSize2 = 0;
     292            pbmi->ulColorEncoding = BCE_RGB;
     293            pbmi->ulIdentifier = 0;
     294
     295            PBYTE pal = ((PBYTE)pbmi) + sizeof( BITMAPINFOHEADER2 );
     296            LuPixbuf *p = new LuPixbuf( ev, rclx, rcly, 1 );
     297
     298            rgb_to_pal8( p, pixbuf, rclx, rcly, pal );
     299
     300            GpiDrawBits( hpsPrinter, p->getDataPtr( ev ), pbmi, 4L,
     301                         aptlPoints, lRop, BBO_IGNORE );
     302            delete p;
     303            free( pbmi );
     304        }
     305        else
     306        {
     307            BITMAPINFO2 pbmi;
     308            pbmi.cbFix = 16L;
     309            pbmi.cx = rclx;
     310            pbmi.cy = rcly;
     311            pbmi.cPlanes = 1;
     312            pbmi.cBitCount = bpp * 8;
     313            GpiDrawBits( hpsPrinter, pixbuf->getDataPtr( ev ), &pbmi, 4L,
     314                         aptlPoints, lRop, BBO_IGNORE );
     315        }
    274316        delete pixbuf;
    275317    }
     
    474516}
    475517
     518
     519// Convert RGB 24/32 bit pixbuf into 8 bit palettized
     520static void rgb_to_pal8( LuPixbuf *dst, LuPixbuf *src, int width, int height, BYTE *p_pal )
     521{
     522    NeuQuantizer *nq = new NeuQuantizer( src, 256 );
     523
     524    nq->initnet();
     525    nq->learn( 10 );
     526    nq->unbiasnet();
     527
     528    int *palette = (int *)nq->getNetwork();
     529    for ( int i = 0; i < ( 256 * 4 ); i++ ) {
     530        p_pal[ i ] = palette[ i ];
     531    }
     532    nq->inxbuild();
     533
     534    unsigned char *p_src = (unsigned char *)src->getDataPtr( ev );
     535    unsigned char *p_dst = (unsigned char *)dst->getDataPtr( ev );
     536    long rowsize_src = src->getRowSize( ev );
     537    long rowsize_dst = dst->getRowSize( ev );
     538    long x = src->getWidth( ev );
     539    long y = src->getHeight( ev );
     540    long bpp = src->getBpp( ev );
     541
     542    for ( long py = 0; py < y; py++ )
     543    {
     544        BYTE *row_src = p_src + ( rowsize_src * py );
     545        long row_dst = rowsize_dst * py;
     546        for ( long px = 0; px < x; px++ )
     547        {
     548            BYTE *pix = row_src + ( px * bpp );
     549            p_dst[ row_dst + px ] = nq->inxsearch( pix[0], pix[1], pix[2] );
     550        }
     551    }
     552
     553    delete nq;
     554}
     555
  • trunk/Lucide/SOURCE/plugins/ludoc/lupixbuf.cpp

    r71 r171  
    5555
    5656
    57 
    58 /*
    59  * SOM_Scope void SOMLINK LuPixbufInit(LuPixbuf *somSelf,  Environment *ev,
    60  *                                     somInitCtrl* ctrl, long w, long h)
    61  */
    62 
    63 /*
    64  * The prototype for LuPixbufInit was replaced by the following prototype:
    65  */
    6657SOM_Scope void SOMLINK LuPixbufInit(LuPixbuf *somSelf,  Environment *ev,
    6758                                    somInitCtrl* ctrl, long w,
Note: See TracChangeset for help on using the changeset viewer.