Question
Help - color loss when transparency value is not 0xff
hi, i'm writing filter plug-in which makes a pink rectangle on the layer,
only differs in transparency each column.
So all pixel color must be same, regardless of transparency.
you see it by 1)making a solid rect on layer, 2) make alpha layer mask and put gradient on it,
3) and apply alpha layer mask.
i expected the same result, but actual result was very strange.
i fill the rectangle in (249, 125, 125) color, but the blue and green color
dramatically drop to zero when transparency value gets lower, here's sample value:
alpha value 0 : (0, 0, 0)
alpha value 40 : (218, 0, 0)
alpha value 160 : (245, 49, 49)
and here's the code:
{
// make 255x10 rect
int32 w = 0xff;
int32 h = 10;
VRect write_rect = {0, 0, h, w};
char* planeBuffer = sPSBuffer->New(NULL, w * h);
PixelMemoryDesc destination;
destination.data = planeBuffer;
destination.depth = 8;
destination.rowBits = w * 8;
destination.colBits = 8;
destination.bitOffset = 0 ;
// fill R/G/B #f97d7d
ReadChannelDesc* chR = gFilterRecord->documentInfo->targetCompositeChannels;
memset(planeBuffer, 0xf9, w * h);
sPSChannelProcs->WritePixelsToBaseLevel(chR->writePort, &write_rect, &destination);
ReadChannelDesc* chG = chR->next;
memset(planeBuffer, 0x7d, w * h);
sPSChannelProcs->WritePixelsToBaseLevel(chG->writePort, &write_rect, &destination);
ReadChannelDesc* chB = chG->next;
memset(planeBuffer, 0x7d, w * h);
sPSChannelProcs->WritePixelsToBaseLevel(chB->writePort, &write_rect, &destination);
// fill alpha channel 0~0xff
ReadChannelDesc* chA = gFilterRecord->documentInfo->targetTransparency;
for (int32 y=0; y < h; y++)
{
for (int32 x=0; x < w; x++)
{
planeBuffer[y*w+x] = (x % 0xff);
}
}
sPSChannelProcs->WritePixelsToBaseLevel(chA->writePort, &write_rect, &destination);
// dispose.
sPSBuffer->Dispose(&planeBuffer);
}
Am i doing something wrong?
only differs in transparency each column.
So all pixel color must be same, regardless of transparency.
you see it by 1)making a solid rect on layer, 2) make alpha layer mask and put gradient on it,
3) and apply alpha layer mask.
i expected the same result, but actual result was very strange.
i fill the rectangle in (249, 125, 125) color, but the blue and green color
dramatically drop to zero when transparency value gets lower, here's sample value:
alpha value 0 : (0, 0, 0)
alpha value 40 : (218, 0, 0)
alpha value 160 : (245, 49, 49)
and here's the code:
{
// make 255x10 rect
int32 w = 0xff;
int32 h = 10;
VRect write_rect = {0, 0, h, w};
char* planeBuffer = sPSBuffer->New(NULL, w * h);
PixelMemoryDesc destination;
destination.data = planeBuffer;
destination.depth = 8;
destination.rowBits = w * 8;
destination.colBits = 8;
destination.bitOffset = 0 ;
// fill R/G/B #f97d7d
ReadChannelDesc* chR = gFilterRecord->documentInfo->targetCompositeChannels;
memset(planeBuffer, 0xf9, w * h);
sPSChannelProcs->WritePixelsToBaseLevel(chR->writePort, &write_rect, &destination);
ReadChannelDesc* chG = chR->next;
memset(planeBuffer, 0x7d, w * h);
sPSChannelProcs->WritePixelsToBaseLevel(chG->writePort, &write_rect, &destination);
ReadChannelDesc* chB = chG->next;
memset(planeBuffer, 0x7d, w * h);
sPSChannelProcs->WritePixelsToBaseLevel(chB->writePort, &write_rect, &destination);
// fill alpha channel 0~0xff
ReadChannelDesc* chA = gFilterRecord->documentInfo->targetTransparency;
for (int32 y=0; y < h; y++)
{
for (int32 x=0; x < w; x++)
{
planeBuffer[y*w+x] = (x % 0xff);
}
}
sPSChannelProcs->WritePixelsToBaseLevel(chA->writePort, &write_rect, &destination);
// dispose.
sPSBuffer->Dispose(&planeBuffer);
}
Am i doing something wrong?
