joycode / hqx

Automatically exported from code.google.com/p/hqx
GNU Lesser General Public License v2.1
0 stars 1 forks source link

rowbytes are assumed #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. wish that rowbytes could be explicitly specified
2. become disappointed
3. open a new issue on the project page

What is the expected output? 
that the rows align properly

What do you see instead?
they severely misalign if your rowbytes != columns * pixelsize

What version of the product are you using? On what operating system?
latest, darwin

Please provide any additional information below.
i fiddled for a bit trying to pass in source and dest rowbytes, but got a bit 
lost.  i could probably figure it out, but perhaps someone with better domain 
knowledge could do a better job?

the point here is to avoid 2 extra bitmap copies.  currently, i have my pic in 
a bitmap, my code goes like this:

1) copy from bitmap to pixel vector (squeezes out extra space at the end of 
rows)
2) perform upconvert
3) copy from output pixel vector to output bitmap
4) blit bitmap

i'd sure like to skip steps 1 and 3!

Original issue reported on code.google.com by anbaricf...@gmail.com on 20 Sep 2011 at 10:26

GoogleCodeExporter commented 8 years ago
figured it out:

at the top of hq4x do this:

HQX_API void HQX_CALLCONV hq4x_32_rb( uint32_t * sp, uint32_t srb, uint32_t * 
dp, uint32_t drb, int Xres, int Yres )
{
    int         i, j, k;
    int         prevline, nextline;
    uint32_t        w[10];
    int         dpL = (drb >> 2);
    uint8_t     *sRowP = (uint8_t *)sp;
    uint8_t     *dRowP = (uint8_t *)dp;

    for (j=0; j<Yres; j++) {
        if (j>0)      prevline = -(int)(srb >> 2); else prevline = 0;
        if (j<Yres-1) nextline =  (srb >> 2); else nextline = 0;
---------------
at the bottom:
---------------
            sp++;
            dp += 4;
        }

    sRowP += srb;
    sp = (uint32_t *)sRowP;

    dRowP += drb * 4;
    dp = (uint32_t *)dRowP;
    }

Original comment by anbaricf...@gmail.com on 21 Sep 2011 at 6:49

GoogleCodeExporter commented 8 years ago
for backward compatibility:

HQX_API void HQX_CALLCONV hq4x_32( uint32_t * sp, uint32_t * dp, int Xres, int 
Yres )
{
    uint32_t        rowBytesL = Xres * 4;

    hq4x_32_rb(sp, rowBytesL, dp, rowBytesL * 4, Xres, Yres);
}

Original comment by anbaricf...@gmail.com on 21 Sep 2011 at 6:50

GoogleCodeExporter commented 8 years ago
I'll incorporate this when I get the chance.

Original comment by grom...@gmail.com on 1 Dec 2011 at 11:08

GoogleCodeExporter commented 8 years ago
Have integrated this change for all versions of the scale function.

Original comment by grom...@gmail.com on 5 Dec 2011 at 12:40