Skip to main content
Inspiring
January 5, 2022
Answered

Load colour table (index color)

  • January 5, 2022
  • 1 reply
  • 1055 views

This should be straightforward, I want to load a colour table .ACT from a script only the code from the scriptlistener explicitly looks at each RGB entry:

// =======================================================
var idCnvM = charIDToTypeID( "CnvM" );
    var desc13758 = new ActionDescriptor();
    var idT = charIDToTypeID( "T   " );
        var desc13759 = new ActionDescriptor();
        var idCstP = charIDToTypeID( "CstP" );
            var list1363 = new ActionList();
                var desc13760 = new ActionDescriptor();
                var idRd = charIDToTypeID( "Rd  " );
                desc13760.putDouble( idRd, 196.000000 );
                var idGrn = charIDToTypeID( "Grn " );
                desc13760.putDouble( idGrn, 28.000000 );
                var idBl = charIDToTypeID( "Bl  " );
                desc13760.putDouble( idBl, 56.000000 );
            var idRGBC = charIDToTypeID( "RGBC" );
            list1363.putObject( idRGBC, desc13760 );
                var desc13761 = new ActionDescriptor();
                var idRd = charIDToTypeID( "Rd  " );
                desc13761.putDouble( idRd, 96.000000 );
                var idGrn = charIDToTypeID( "Grn " );
                desc13761.putDouble( idGrn, 96.000000 );
                var idBl = charIDToTypeID( "Bl  " );
                desc13761.putDouble( idBl, 128.000000 );
            var idRGBC = charIDToTypeID( "RGBC" );
            list1363.putObject( idRGBC, desc13761 );
                var desc13762 = new ActionDescriptor();
                var idRd = charIDToTypeID( "Rd  " );
                desc13762.putDouble( idRd, 129.000000 );
                var idGrn = charIDToTypeID( "Grn " );
                desc13762.putDouble( idGrn, 127.000000 );
                var idBl = charIDToTypeID( "Bl  " );
                desc13762.putDouble( idBl, 127.000000 );
            var idRGBC = charIDToTypeID( "RGBC" );
            list1363.putObject( idRGBC, desc13762 );
                var desc13763 = new ActionDescriptor();
                var idRd = charIDToTypeID( "Rd  " );
                desc13763.putDouble( idRd, 93.000000 );
                var idGrn = charIDToTypeID( "Grn " );
                desc13763.putDouble( idGrn, 93.000000 );
                var idBl = charIDToTypeID( "Bl  " );
                desc13763.putDouble( idBl, 93.000000 );
            var idRGBC = charIDToTypeID( "RGBC" );
            list1363.putObject( idRGBC, desc13763 );
        desc13759.putList( idCstP, list1363 );
    var idIndC = charIDToTypeID( "IndC" );
    desc13758.putObject( idT, idIndC, desc13759 );
executeAction( idCnvM, desc13758, DialogModes.NO );

 

Not what I'm after. Also the code is very ugly, and that's only for 4 colours and is incrementally longer for more colour values.

 

Is there the equivilant of  this?

Image > Mode > Color Table... > Custom > Load... (pick mypalette.act) :

 

load_palette("C:\mypalette.act";

function load_palette(apath)
{
	// magic code here
}

.

 

Cheers.

This topic has been closed for replies.

1 reply

r-binCorrect answer
Legend
January 5, 2022
Kukurykus
Legend
January 5, 2022

He already knows that: second link

Legend
January 5, 2022
quote

He already knows that: second link


By @Kukurykus

 

My link points to the specific code he(her) needs