Changeset 214 for trunk/Lucide


Ignore:
Timestamp:
Aug 1, 2007, 6:42:43 PM (14 years ago)
Author:
Eugene Romanenko
Message:

Quality scaling in JPEG plugin (still buggy)

Location:
trunk/Lucide
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Lucide/SOURCE/gui/makefile

    r208 r214  
    22
    33TEST=0
    4 VERSION=1.01
     4VERSION=1.02
    55
    66!if $(TEST)==1
  • trunk/Lucide/SOURCE/plugins/lujpeg/lujpeg.cpp

    r155 r214  
    5858
    5959#include <stdio.h>
     60#include <stdlib.h>
    6061#include <string.h>
    6162#include <setjmp.h>
     
    6364
    6465
     66void resample( Environment *ev,
     67               LuPixbuf *out, int out_x0, int out_y0, int out_x1, int out_y1,
     68               LuPixbuf *in, float in_x0, float in_y0, float in_x1, float in_y1 );
    6569
    6670unsigned _System LibMain( unsigned hmod, unsigned termination )
     
    200204
    201205
     206SOM_Scope boolean  SOMLINK isScalable(LuJpegDocument *somSelf,
     207                                       Environment *ev)
     208{
     209    return TRUE;
     210}
     211
    202212SOM_Scope long  SOMLINK getPageCount(LuJpegDocument *somSelf,
    203213                                      Environment *ev)
     
    240250    JpegDocument *d = (JpegDocument *)somThis->data;
    241251
    242     //somPrintf( "src_x: %d  src_y: %d  src_width: %d  src_height: %d\n",
    243     //            src_x, src_y, src_width, src_height );
     252    //somPrintf( "src_x: %d  src_y: %d  src_width: %d  src_height: %d  scale: %f\n",
     253    //            src_x, src_y, src_width, src_height, scale );
     254
     255    long real_src_x = ( (double)src_x / scale );
     256    long real_src_y = ( (double)src_y / scale );
     257    long real_src_width = ( (double)src_width / scale );
     258    long real_src_height = ( (double)src_height / scale );
    244259
    245260    short bpp = getBpp( somSelf, ev );
     261
    246262    int pb_rowstride = d->pb->getRowSize( ev );
    247     int pb_height = d->pb->getHeight( ev );
    248     int pixbuf_rowstride = pixbuf->getRowSize( ev );
    249     char *pb_data = (char *)d->pb->getDataPtr( ev );
    250     char *pixbuf_data = (char *)pixbuf->getDataPtr( ev );
     263    int pb_width     = d->pb->getWidth( ev );
     264    int pb_height    = d->pb->getHeight( ev );
     265    char *pb_data    = (char *)d->pb->getDataPtr( ev );
     266
     267    real_src_width   = __min( real_src_width, pb_width );
     268    real_src_height  = __min( real_src_height, pb_height );
     269
     270    LuPixbuf *tmp = new LuPixbuf( ev, real_src_width, real_src_height, bpp );
     271    int pixbuf_rowstride = tmp->getRowSize( ev );
     272    char *pixbuf_data = (char *)tmp->getDataPtr( ev );
    251273    char *src, *dst;
    252274    int i, y;
    253     for ( y = pb_height-(src_y+src_height), i = 0; i < src_height; y++, i++ )
     275    //somPrintf( "0: %d | %d | %d\n", pb_height, real_src_y, real_src_height );
     276    for ( y = pb_height-(real_src_y+real_src_height), i = 0; i < real_src_height; y++, i++ )
    254277    {
    255         src = pb_data + (y * pb_rowstride) + (src_x * bpp);
     278        //somPrintf( "1: %x | %d | %d | %d | %d\n", pb_data, y, pb_rowstride, real_src_x, bpp );
     279        src = pb_data + (y * pb_rowstride) + (real_src_x * bpp);
    256280        dst = pixbuf_data + (i * pixbuf_rowstride);
    257         memcpy( dst, src, src_width * bpp );
    258     }
     281        memcpy( dst, src, real_src_width * bpp );
     282    }
     283
     284    char *dt = (char *)pixbuf->getDataPtr( ev );
     285    if ( scale == 1.0 )
     286    {
     287        memcpy( dt, pixbuf_data, pixbuf->getDataLen( ev ) );
     288    }
     289    else
     290    {
     291        if ( ( real_src_width > 0 ) && ( real_src_height > 0 ) )
     292        {
     293            resample( ev, pixbuf, 0, 0, src_width-1, src_height-1,
     294                          tmp, 0, 0, real_src_width, real_src_height );
     295        }
     296    }
     297    delete tmp;
    259298
    260299    return TRUE;
  • trunk/Lucide/SOURCE/plugins/lujpeg/lujpeg.idl

    r94 r214  
    2525        loadFile: override;
    2626        getBpp: override;
     27        isScalable: override;
    2728        getPageCount: override;
    2829        getPageSize: override;
  • trunk/Lucide/SOURCE/plugins/lujpeg/lujpeg.xih

    r155 r214  
    143143  #define _loadFile somSelf->loadFile
    144144  #define _getBpp somSelf->getBpp
     145  #define _isScalable somSelf->isScalable
    145146  #define _getPageCount somSelf->getPageCount
    146147  #define _getPageSize somSelf->getPageSize
     
    247248#define LuJpegDocument_parents_getBpp(somSelf,ev) (\
    248249   LuJpegDocument_parent_LuDocument_getBpp(somSelf,ev))
     250
     251/*
     252 * Overridden method: isScalable
     253 */
     254SOM_Scope boolean  SOMLINK isScalable(LuJpegDocument *somSelf, Environment *ev);
     255static char *somMN_LuJpegDocumentisScalable = "LuDocument::isScalable";
     256static somId somId_LuJpegDocumentisScalable = &somMN_LuJpegDocumentisScalable;
     257#ifdef somId_isScalable
     258#undef somId_isScalable
     259#else
     260#define somId_isScalable somId_LuJpegDocumentisScalable
     261#endif
     262typedef boolean   SOMLINK somTP_xih_LuJpegDocument_isScalable(LuJpegDocument *somSelf, Environment *ev);
     263typedef somTP_xih_LuJpegDocument_isScalable *somTD_xih_LuJpegDocument_isScalable;
     264/* define the parent method call macro */
     265static somMethodProc* LuJpegDocument_parent_LuDocument_isScalable_resolved;
     266#define LuJpegDocument_parent_LuDocument_isScalable(somSelf,ev) \
     267  ((( somTD_xih_LuJpegDocument_isScalable ) \
     268      LuJpegDocument_parent_LuDocument_isScalable_resolved) \
     269        (somSelf,ev))
     270/* define a variety of (possibly ambiguous) short forms */
     271#ifndef SOMGD_pmc_parent_isScalable
     272  #ifdef parent_isScalable
     273    #define SOMGD_pmc_parent_isScalable
     274    #undef parent_isScalable
     275  #else
     276#define parent_isScalable LuJpegDocument_parent_LuDocument_isScalable
     277  #endif
     278#endif
     279#ifndef SOMGD_pmc_parent_LuDocument_isScalable
     280  #ifdef parent_LuDocument_isScalable
     281    #define SOMGD_pmc_parent_LuDocument_isScalable
     282    #undef parent_LuDocument_isScalable
     283  #else
     284    #define parent_LuDocument_isScalable LuJpegDocument_parent_LuDocument_isScalable
     285  #endif
     286#endif
     287#define LuJpegDocument_parents_isScalable(somSelf,ev) (\
     288   LuJpegDocument_parent_LuDocument_isScalable(somSelf,ev))
    249289
    250290/*
     
    431471    {    &somId_LuJpegDocumentgetBpp,
    432472         (somMethodProc *) getBpp  },
     473    {    &somId_LuJpegDocumentisScalable,
     474         (somMethodProc *) isScalable  },
    433475    {    &somId_LuJpegDocumentgetPageCount,
    434476         (somMethodProc *) getPageCount  },
     
    455497
    456498static somStaticClassInfo LuJpegDocumentSCI = {
    457     4, 0, 7, 0, 0, 0, /* layout version 4 */
     499    4, 0, 8, 0, 0, 0, /* layout version 4 */
    458500    LuJpegDocument_MajorVersion, LuJpegDocument_MinorVersion,
    459501    sizeof(LuJpegDocumentData), LuJpegDocument_MaxNoMethods, 1,
     
    507549    LuJpegDocument_parent_LuDocument_getPageCount_resolved =
    508550        somParentNumResolve(LuJpegDocumentCClassData.parentMtab, 1, LuDocumentClassData.getPageCount);
     551    LuJpegDocument_parent_LuDocument_isScalable_resolved =
     552        somParentNumResolve(LuJpegDocumentCClassData.parentMtab, 1, LuDocumentClassData.isScalable);
    509553    LuJpegDocument_parent_LuDocument_getBpp_resolved =
    510554        somParentNumResolve(LuJpegDocumentCClassData.parentMtab, 1, LuDocumentClassData.getBpp);
  • trunk/Lucide/SOURCE/plugins/lujpeg/makefile

    r143 r214  
    2222
    2323
    24 lujpeg.dll: lujpeg.obj ..\ludoc\ludoc.lib
     24lujpeg.dll: lujpeg.obj jpscale.obj ..\ludoc\ludoc.lib
    2525  copy &&|
    2626option quiet
     
    2929option statics
    3030file $(OBJDIR)\lujpeg.obj
     31file $(OBJDIR)\jpscale.obj
    3132name $(EXEDIR)\lujpeg
    3233lib ..\..\..\..\libjpeg\libjpeg.lib
  • trunk/Lucide/readme

    r196 r214  
    2020  --------------------------------------------------------------------------
    2121
    22 This program requires UClip package (enhanced OS/2 clipboard support)
    23 and Innotek LIBC:
     22This program requires UClip package (enhanced OS/2 clipboard support):
    2423
    2524  - http://hobbes.nmsu.edu/cgi-bin/h-search?key=UClip
    26   - ftp://ftp.netlabs.org/pub/gcc/libc-0.6.1-csd1.zip
     25 
     26UClip requires Innotek LIBC 0.6.1:
     27 
     28  - ftp://ftp.netlabs.org/pub/gcc/libc-0.6.1-csd1.zip (zip format)
     29    or ftp://ftp.netlabs.org/pub/gcc/libc-0_6_1-csd1.wpi (WarpIn format)
     30
     31DJVU plugin requires Innotek LIBC 0.6.3:
     32 
     33  - ftp://ftp.netlabs.org/pub/gcc/libc-0.6.3-csd3.zip (zip format)
     34    or ftp://ftp.netlabs.org/pub/gcc/libc-0_6_3-csd3.wpi (WarpIn format)
    2735
    2836
     
    93101:: Copyright ::
    94102
    95 (c) 2006 by Eugene Romanenko, netlabs.org
     103(c) 2006-2007 by Eugene Romanenko, netlabs.org
    96104    in co-operation with Serenity Systems International
Note: See TracChangeset for help on using the changeset viewer.