|
|
|
@ -653,8 +653,8 @@ void XCFImageFormat::composeTiles ( XCFImage& xcf_image )
|
|
|
|
|
if ( layer.type == GRAYA_GIMAGE || layer.type == INDEXEDA_GIMAGE )
|
|
|
|
|
layer.alpha_tiles.resize( layer.nrows );
|
|
|
|
|
|
|
|
|
|
if ( layer.tqmask_offset != 0 )
|
|
|
|
|
layer.tqmask_tiles.resize( layer.nrows );
|
|
|
|
|
if ( layer.mask_offset != 0 )
|
|
|
|
|
layer.mask_tiles.resize( layer.nrows );
|
|
|
|
|
|
|
|
|
|
for ( uint j = 0; j < layer.nrows; j++ ) {
|
|
|
|
|
layer.image_tiles[j].resize( layer.ncols );
|
|
|
|
@ -662,8 +662,8 @@ void XCFImageFormat::composeTiles ( XCFImage& xcf_image )
|
|
|
|
|
if ( layer.type == GRAYA_GIMAGE || layer.type == INDEXEDA_GIMAGE )
|
|
|
|
|
layer.alpha_tiles[j].resize( layer.ncols );
|
|
|
|
|
|
|
|
|
|
if ( layer.tqmask_offset != 0 )
|
|
|
|
|
layer.tqmask_tiles[j].resize( layer.ncols );
|
|
|
|
|
if ( layer.mask_offset != 0 )
|
|
|
|
|
layer.mask_tiles[j].resize( layer.ncols );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for ( uint j = 0; j < layer.nrows; j++ ) {
|
|
|
|
@ -717,9 +717,9 @@ void XCFImageFormat::composeTiles ( XCFImage& xcf_image )
|
|
|
|
|
setGrayPalette( layer.alpha_tiles[j][i] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( layer.tqmask_offset != 0 ) {
|
|
|
|
|
layer.tqmask_tiles[j][i] = TQImage( tile_width, tile_height, 8, 256 );
|
|
|
|
|
setGrayPalette( layer.tqmask_tiles[j][i] );
|
|
|
|
|
if ( layer.mask_offset != 0 ) {
|
|
|
|
|
layer.mask_tiles[j][i] = TQImage( tile_width, tile_height, 8, 256 );
|
|
|
|
|
setGrayPalette( layer.mask_tiles[j][i] );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -874,7 +874,7 @@ bool XCFImageFormat::loadLayer ( SafeDataStream& xcf_io, XCFImage& xcf_image )
|
|
|
|
|
|
|
|
|
|
// If there are any more layers, merge them into the final TQImage.
|
|
|
|
|
|
|
|
|
|
xcf_io >> layer.hierarchy_offset >> layer.tqmask_offset;
|
|
|
|
|
xcf_io >> layer.hierarchy_offset >> layer.mask_offset;
|
|
|
|
|
|
|
|
|
|
if ( xcf_io.failed() ) {
|
|
|
|
|
qDebug( "XCF: read failure on layer image offsets" );
|
|
|
|
@ -896,8 +896,8 @@ bool XCFImageFormat::loadLayer ( SafeDataStream& xcf_io, XCFImage& xcf_image )
|
|
|
|
|
|
|
|
|
|
if ( !loadHierarchy( xcf_io, layer ) ) return false;
|
|
|
|
|
|
|
|
|
|
if ( layer.tqmask_offset != 0 ) {
|
|
|
|
|
xcf_io.device()->at( layer.tqmask_offset );
|
|
|
|
|
if ( layer.mask_offset != 0 ) {
|
|
|
|
|
xcf_io.device()->at( layer.mask_offset );
|
|
|
|
|
|
|
|
|
|
if ( !loadMask( xcf_io, layer ) ) return false;
|
|
|
|
|
}
|
|
|
|
@ -1018,24 +1018,24 @@ bool XCFImageFormat::loadChannelProperties ( SafeDataStream& xcf_io, Layer& laye
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case PROP_OPACITY:
|
|
|
|
|
property >> layer.tqmask_channel.opacity;
|
|
|
|
|
property >> layer.mask_channel.opacity;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_VISIBLE:
|
|
|
|
|
property >> layer.tqmask_channel.visible;
|
|
|
|
|
property >> layer.mask_channel.visible;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_SHOW_MASKED:
|
|
|
|
|
property >> layer.tqmask_channel.show_tqmasked;
|
|
|
|
|
property >> layer.mask_channel.show_masked;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_COLOR:
|
|
|
|
|
property >> layer.tqmask_channel.red >> layer.tqmask_channel.green
|
|
|
|
|
>> layer.tqmask_channel.blue;
|
|
|
|
|
property >> layer.mask_channel.red >> layer.mask_channel.green
|
|
|
|
|
>> layer.mask_channel.blue;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PROP_TATTOO:
|
|
|
|
|
property >> layer.tqmask_channel.tattoo;
|
|
|
|
|
property >> layer.mask_channel.tattoo;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
@ -1377,7 +1377,7 @@ void XCFImageFormat::assignImageBytes ( Layer& layer, uint i, uint j )
|
|
|
|
|
for ( int l = 0; l < layer.image_tiles[j][i].height(); l++ ) {
|
|
|
|
|
for ( int k = 0; k < layer.image_tiles[j][i].width(); k++ ) {
|
|
|
|
|
|
|
|
|
|
// The "if" here should not be necessary, but aptqparently there
|
|
|
|
|
// The "if" here should not be necessary, but apparently there
|
|
|
|
|
// are some cases where the image can contain larger indices
|
|
|
|
|
// than there are colors in the palette. (A bug in The GIMP?)
|
|
|
|
|
|
|
|
|
@ -1404,7 +1404,7 @@ void XCFImageFormat::assignMaskBytes ( Layer& layer, uint i, uint j )
|
|
|
|
|
|
|
|
|
|
for ( int l = 0; l < layer.image_tiles[j][i].height(); l++ ) {
|
|
|
|
|
for ( int k = 0; k < layer.image_tiles[j][i].width(); k++ ) {
|
|
|
|
|
layer.tqmask_tiles[j][i].setPixel( k, l, tile[0] );
|
|
|
|
|
layer.mask_tiles[j][i].setPixel( k, l, tile[0] );
|
|
|
|
|
tile += sizeof(TQRgb);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1555,7 +1555,7 @@ void XCFImageFormat::copyLayerToImage ( XCFImage& xcf_image )
|
|
|
|
|
|
|
|
|
|
// This seems the best place to apply the dissolve because it
|
|
|
|
|
// depends on the global position of each tile's
|
|
|
|
|
// pixels. Aptqparently it's the only mode which can apply to a
|
|
|
|
|
// pixels. Apparently it's the only mode which can apply to a
|
|
|
|
|
// single layer.
|
|
|
|
|
|
|
|
|
|
if ( layer.mode == DISSOLVE_MODE ) {
|
|
|
|
@ -1607,9 +1607,9 @@ void XCFImageFormat::copyRGBToRGB ( Layer& layer, uint i, uint j, int k, int l,
|
|
|
|
|
|
|
|
|
|
// Apply the tqmask (if any)
|
|
|
|
|
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.tqmask_tiles.size() > j &&
|
|
|
|
|
layer.tqmask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.tqmask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.mask_tiles.size() > j &&
|
|
|
|
|
layer.mask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.mask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
|
|
|
|
|
image.setPixel( m, n, tqRgba( src, src_a ) );
|
|
|
|
|
}
|
|
|
|
@ -1680,9 +1680,9 @@ void XCFImageFormat::copyGrayAToRGB ( Layer& layer, uint i, uint j, int k, int l
|
|
|
|
|
|
|
|
|
|
// Apply the tqmask (if any)
|
|
|
|
|
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.tqmask_tiles.size() > j &&
|
|
|
|
|
layer.tqmask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.tqmask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.mask_tiles.size() > j &&
|
|
|
|
|
layer.mask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.mask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
|
|
|
|
|
image.setPixel( m, n, tqRgba( src, src_a ) );
|
|
|
|
|
}
|
|
|
|
@ -1727,10 +1727,10 @@ void XCFImageFormat::copyIndexedAToIndexed ( Layer& layer,uint i,uint j,int k,in
|
|
|
|
|
src_a = INT_MULT( src_a, layer.opacity );
|
|
|
|
|
|
|
|
|
|
if ( layer.apply_tqmask == 1 &&
|
|
|
|
|
layer.tqmask_tiles.size() > j &&
|
|
|
|
|
layer.tqmask_tiles[j].size() > i )
|
|
|
|
|
layer.mask_tiles.size() > j &&
|
|
|
|
|
layer.mask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a,
|
|
|
|
|
layer.tqmask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
layer.mask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
|
|
|
|
|
if ( src_a > 127 )
|
|
|
|
|
src++;
|
|
|
|
@ -1764,9 +1764,9 @@ void XCFImageFormat::copyIndexedAToRGB ( Layer& layer, uint i, uint j, int k, in
|
|
|
|
|
|
|
|
|
|
// Apply the tqmask (if any)
|
|
|
|
|
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.tqmask_tiles.size() > j &&
|
|
|
|
|
layer.tqmask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.tqmask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.mask_tiles.size() > j &&
|
|
|
|
|
layer.mask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.mask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
|
|
|
|
|
// This is what appears in the GIMP window
|
|
|
|
|
|
|
|
|
@ -1822,7 +1822,7 @@ void XCFImageFormat::mergeLayerIntoImage ( XCFImage& xcf_image )
|
|
|
|
|
|
|
|
|
|
// This seems the best place to apply the dissolve because it
|
|
|
|
|
// depends on the global position of each tile's
|
|
|
|
|
// pixels. Aptqparently it's the only mode which can apply to a
|
|
|
|
|
// pixels. Apparently it's the only mode which can apply to a
|
|
|
|
|
// single layer.
|
|
|
|
|
|
|
|
|
|
if ( layer.mode == DISSOLVE_MODE ) {
|
|
|
|
@ -2021,9 +2021,9 @@ void XCFImageFormat::mergeRGBToRGB ( Layer& layer, uint i, uint j, int k, int l,
|
|
|
|
|
|
|
|
|
|
// Apply the tqmask (if any)
|
|
|
|
|
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.tqmask_tiles.size() > j &&
|
|
|
|
|
layer.tqmask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.tqmask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.mask_tiles.size() > j &&
|
|
|
|
|
layer.mask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.mask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
|
|
|
|
|
uchar new_r, new_g, new_b, new_a;
|
|
|
|
|
|
|
|
|
@ -2123,9 +2123,9 @@ void XCFImageFormat::mergeGrayAToGray ( Layer& layer, uint i, uint j, int k, int
|
|
|
|
|
|
|
|
|
|
// Apply the tqmask (if any)
|
|
|
|
|
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.tqmask_tiles.size() > j &&
|
|
|
|
|
layer.tqmask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.tqmask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.mask_tiles.size() > j &&
|
|
|
|
|
layer.mask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.mask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
|
|
|
|
|
uchar new_a = OPAQUE_OPACITY;
|
|
|
|
|
|
|
|
|
@ -2234,9 +2234,9 @@ void XCFImageFormat::mergeGrayAToRGB ( Layer& layer, uint i, uint j, int k, int
|
|
|
|
|
|
|
|
|
|
// Apply the tqmask (if any)
|
|
|
|
|
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.tqmask_tiles.size() > j &&
|
|
|
|
|
layer.tqmask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.tqmask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.mask_tiles.size() > j &&
|
|
|
|
|
layer.mask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.mask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
|
|
|
|
|
uchar new_a = dst_a + INT_MULT( OPAQUE_OPACITY - dst_a, src_a );
|
|
|
|
|
|
|
|
|
@ -2291,10 +2291,10 @@ void XCFImageFormat::mergeIndexedAToIndexed ( Layer& layer,uint i,uint j,int k,i
|
|
|
|
|
src_a = INT_MULT( src_a, layer.opacity );
|
|
|
|
|
|
|
|
|
|
if ( layer.apply_tqmask == 1 &&
|
|
|
|
|
layer.tqmask_tiles.size() > j &&
|
|
|
|
|
layer.tqmask_tiles[j].size() > i )
|
|
|
|
|
layer.mask_tiles.size() > j &&
|
|
|
|
|
layer.mask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a,
|
|
|
|
|
layer.tqmask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
layer.mask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
|
|
|
|
|
if ( src_a > 127 ) {
|
|
|
|
|
src++;
|
|
|
|
@ -2326,9 +2326,9 @@ void XCFImageFormat::mergeIndexedAToRGB ( Layer& layer, uint i, uint j, int k, i
|
|
|
|
|
|
|
|
|
|
// Apply the tqmask (if any)
|
|
|
|
|
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.tqmask_tiles.size() > j &&
|
|
|
|
|
layer.tqmask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.tqmask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
if ( layer.apply_tqmask == 1 && layer.mask_tiles.size() > j &&
|
|
|
|
|
layer.mask_tiles[j].size() > i )
|
|
|
|
|
src_a = INT_MULT( src_a, layer.mask_tiles[j][i].pixelIndex( k, l ) );
|
|
|
|
|
|
|
|
|
|
// This is what appears in the GIMP window
|
|
|
|
|
|
|
|
|
@ -2349,7 +2349,7 @@ void XCFImageFormat::mergeIndexedAToRGB ( Layer& layer, uint i, uint j, int k, i
|
|
|
|
|
*/
|
|
|
|
|
void XCFImageFormat::dissolveRGBPixels ( TQImage& image, int x, int y )
|
|
|
|
|
{
|
|
|
|
|
// The aptqparently spurious rand() calls are to wind the random
|
|
|
|
|
// The apparently spurious rand() calls are to wind the random
|
|
|
|
|
// numbers up to the same point for each tile.
|
|
|
|
|
|
|
|
|
|
for ( int l = 0; l < image.height(); l++ ) {
|
|
|
|
@ -2380,7 +2380,7 @@ void XCFImageFormat::dissolveRGBPixels ( TQImage& image, int x, int y )
|
|
|
|
|
*/
|
|
|
|
|
void XCFImageFormat::dissolveAlphaPixels ( TQImage& image, int x, int y )
|
|
|
|
|
{
|
|
|
|
|
// The aptqparently spurious rand() calls are to wind the random
|
|
|
|
|
// The apparently spurious rand() calls are to wind the random
|
|
|
|
|
// numbers up to the same point for each tile.
|
|
|
|
|
|
|
|
|
|
for ( int l = 0; l < image.height(); l++ ) {
|
|
|
|
|