Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Java Script -> VFP Help? - Photoshop Automation
Message
From
09/06/2006 08:29:44
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Java Script -> VFP Help? - Photoshop Automation
Miscellaneous
Thread ID:
01128088
Message ID:
01128088
Views:
93
I need some help translating this java script code into VFP...

I'm trying to automate using the CHANNELMIXER of photoshop CS with VFP as an automation client. I got help from somebody with a bit of code that unfortunately is a rather foreign language to me. The sample code follows later.

From what I understand I should start with something like


lcSourceFile = "c:\temp\pic_12345.jpg"
oPhotoshop = CREATEOBJECT( "Photoshop.Application" )
docRef = THISFORM.oPhotoshop.OPEN(lcSourceFile)

oActionReference = CREATEOBJECT("Photoshop.actionreference)

Then somehow I need to establish the object refrerences so that I can address CHANNELMIXER and pass it four values for red, green, blue and constant (for example: 50,50,0,0 for the equivalent of a yellow filter in b&w analog photography).

Can anybody help with the translation of the syntax?

Here is the original mail and code:

Here is the function that I use for channel mixer adjustment layer. To really be effective the user need to preview the settings. So this works in two modes. Call it with parameters to make the layer without a dialog or call it without for a dialog. The dialog is a little different than the GUI dialog in that it asks for the new layer name before the settings. In the GUI it just displays the setting dialog

Code:
function channelMixer( red, green, blue, constant) { 
function cTID(s) { return app.charIDToTypeID(s); }; 
   if(red == undefined){ 
      red = 100;green = 0;blue = 0;constant = 0; 
      var mode = DialogModes.ALL; 
   }else{ 
      var mode = DialogModes.NO; 
   };    
    var desc = new ActionDescriptor(); 
        var ref = new ActionReference(); 
        ref.putClass( cTID('AdjL') ); 
    desc.putReference( cTID('null'), ref ); 
        var chanMixer = new ActionDescriptor(); 
            var mixDesc = new ActionDescriptor(); 
            mixDesc.putBoolean( cTID('Mnch'), true ); 
                var chanDesc = new ActionDescriptor(); 
                chanDesc.putUnitDouble( cTID('Rd  '), cTID('#Prc'), red ); 
                chanDesc.putUnitDouble( cTID('Grn '), cTID('#Prc'), green ); 
                chanDesc.putUnitDouble( cTID('Bl  '), cTID('#Prc'), blue ); 
                chanDesc.putUnitDouble( cTID('Cnst'), cTID('#Prc'), constant ); 
            mixDesc.putObject( cTID('Gry '), cTID('ChMx'), chanDesc ); 
        chanMixer.putObject( cTID('Type'), cTID('ChnM'), mixDesc ); 
    desc.putObject( cTID('Usng'), cTID('AdjL'), chanMixer ); 
    executeAction( cTID('Mk  '), desc, mode ); 
}; 
channelMixer(50,30,25,0);// all four reguired for no dialog 
//or 
channelMixer();// dialog mode
PS: after a lot of searching I found rather helpful object model info for photoshop under http://phrogz.net/ObjJob/objects.asp?langID=9
Teddy Billewicz - MyViewFotoArt
Reply
Map
View

Click here to load this message in the networking platform