从数据库和文件夹中读取图片并且resize

 

从数据库和文件夹中读取图片并且resize

container           c,cImage;

    str                 PicfileName;

    int                 w,h,tmp;

    real                bmpW = bmp1.widthValue(),bmpH = bmp1.heightValue();

    image               img = new image();

    Act_DesignNoTable   Act_DesignNoTable;

    DocuImgS            DocuImgS;

    binData             Bin = new BinData();

    ;

 

    if (!_itemid && !_ACT_DesignNo)

    return c;

    PicfileName = DocuRef::NJ_findRefId_Sketch(TableNum(Act_DesignNoTable),

    Act_DesignNoTable::find(InventTable::find(_itemid).ACT_DesignNo).RecId).completeFilename();

    if (winapi::fileExists(PicfileName))

    {

        img.loadImage(PicfileName);

 

    }

     else

     {

        cImage = DocuImgS::getBitmap(tablenum(Act_DesignNoTable), Act_DesignNoTable::find(_ACT_DesignNo).RecId);

        if (conlen(cImage) > 0)

            img.setData(cImage);

        else

            return c;

     }

        w = img.width();

        h = img.height();

        tmp = img.size();

        if (w>h)

        {

              img.resize(138,138/(w/h),interpolationMode::InterpolationModeHighQuality);

        }

        else

        {

              img.resize(138*(w/h),138,interpolationMode::InterpolationModeHighQuality);

        }

        return img.getData();

-----------------------------

date2str(ACT_InvoiceTable.InvoiceDate,123,2,1,3,1,4) +"\n";

posted @ 2011-07-28 08:59  perock  阅读(391)  评论(0编辑  收藏  举报