Changeset 3399


Ignore:
Timestamp:
02/21/09 15:26:32 (4 years ago)
Author:
sam
Message:

Properly handle alpha components in the convolution code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpipi/trunk/pipi/filter/convolution.c

    r3342 r3399  
    135135        for(x = 0; x < w; x++) 
    136136        { 
    137             double R = 0., G = 0., B = 0.; 
     137            double R = 0., G = 0., B = 0., A = 0.; 
    138138            double Y = 0.; 
    139139            int x2, y2, off = 4 * (y * w + x); 
     
    160160                        G += f * srcdata[(y2 * w + x2) * 4 + 1]; 
    161161                        B += f * srcdata[(y2 * w + x2) * 4 + 2]; 
     162                        A += f * srcdata[(y2 * w + x2) * 4 + 3]; 
    162163                    } 
    163164                } 
     
    171172                dstdata[off + 1] = G < 0.0 ? 0.0 : G > 1.0 ? 1.0 : G; 
    172173                dstdata[off + 2] = B < 0.0 ? 0.0 : B > 1.0 ? 1.0 : B; 
     174                dstdata[off + 3] = A < 0.0 ? 0.0 : A > 1.0 ? 1.0 : A; 
    173175            } 
    174176        } 
     
    205207        for(x = 0; x < w; x++) 
    206208        { 
    207             double R = 0., G = 0., B = 0.; 
     209            double R = 0., G = 0., B = 0., A = 0.; 
    208210            double Y = 0.; 
    209211            int x2, off = 4 * (y * w + x); 
     
    224226                    G += f * srcdata[(y * w + x2) * 4 + 1]; 
    225227                    B += f * srcdata[(y * w + x2) * 4 + 2]; 
     228                    A += f * srcdata[(y * w + x2) * 4 + 3]; 
    226229                } 
    227230            } 
     
    234237                buffer[off + 1] = G; 
    235238                buffer[off + 2] = B; 
     239                buffer[off + 3] = A; 
    236240            } 
    237241        } 
     
    242246        for(x = 0; x < w; x++) 
    243247        { 
    244             double R = 0., G = 0., B = 0.; 
     248            double R = 0., G = 0., B = 0., A = 0.; 
    245249            double Y = 0.; 
    246250            int y2, off = 4 * (y * w + x); 
     
    261265                    G += f * buffer[(y2 * w + x) * 4 + 1]; 
    262266                    B += f * buffer[(y2 * w + x) * 4 + 2]; 
     267                    A += f * buffer[(y2 * w + x) * 4 + 3]; 
    263268                } 
    264269            } 
     
    271276                dstdata[off + 1] = G < 0.0 ? 0.0 : G > 1.0 ? 1.0 : G; 
    272277                dstdata[off + 2] = B < 0.0 ? 0.0 : B > 1.0 ? 1.0 : B; 
     278                dstdata[off + 3] = A < 0.0 ? 0.0 : A > 1.0 ? 1.0 : A; 
    273279            } 
    274280        } 
Note: See TracChangeset for help on using the changeset viewer.