1

const unsigned short *src = cache_.constData() + offy*dia + offx;
    const unsigned int nextline = (image.width() - dia + offx) * 4;

    const unsigned int w = (pos.x()+dia)>image.width()?image.width()-pos.x():dia;
    const unsigned int h = (pos.y()+dia)>image.height()?image.height()-pos.y():dia;

    // Composite brush on image
    for(unsigned int y=offy;y<h;++y)
    {
        for(unsigned int x=offx;x<w;++x)
        {
            const int a = *(src++);
#ifdef IS_BIG_ENDIAN
            ++dest;
            *dest = a*(red - *dest) / 256 + *dest; ++dest;
            *dest = a*(green - *dest) / 256 + *dest; ++dest;
            *dest = a*(blue - *dest) / 256 + *dest; ++dest;
#else
            *dest = a*(blue - *dest) / 256 + *dest; ++dest;
            *dest = a*(green - *dest) / 256 + *dest; ++dest;
            *dest = a*(red - *dest) / 256 + *dest; ++dest;
            ++dest;
#endif
        }
        dest += nextline + (dia-w)*4;
        src += offx + dia-w;
    }

 

posted @ 2023-02-04 11:45  麦田HH  阅读(16)  评论(0编辑  收藏  举报