Skip to main content
Participant
May 23, 2006
Frage

Visual Foxpro (VFP): Background color for ResizeCanvas - how?

  • May 23, 2006
  • 1 Antwort
  • 1357 Ansichten
I'm using Visual Foxpro to automate certain tasks with photoshop.

I can open an image file, save it as something else, extend the canvas, but I cannot set the color for the canvas that gets added.

Somewhere in the application model for Photoshop (CS) must be an object property to set the background color to some kind of value representing for example a certain grey.

Has anybody worked with this

General approach in my VFP-Code:

PUBLIC oPhotoshop
oPhotoshop = CREATEOBJECT( "Photoshop.Application" )

oJPEGSaveOptions = CREATEOBJECT("Photoshop.JPEGSaveOptions")
oJPEGSaveOptions.quality = 8

lnNewH = 800

docRef.resizeCanvas(lnNewH ,lnNewH ,5) && 5 = extend to all sides with active background color

docRef.SAVEAS(lcfilename2, oJPEGSaveOptions, .F.)
Dieses Thema wurde für Antworten geschlossen.

1 Antwort

Participating Frequently
June 1, 2006
This sounds like more of a scripting question than a SDK question, so in JavaScript I would do something like this:

// retrieve the current background color
var oldColor = new SolidColor();
oldColor = app.backgroundColor;

// create a new SolidColor object and assign a color value
var newColor = new SolidColor();
newColor.rgb.red = 100; //or whatever red value you want
newColor.rgb.green = 150; //ditto green
newColor.rgb.blue = 200; //ditto blue

// set the Application backgroundColor property to the new color
app.backgroundColor = newColor;

/////////////////////////////////
// do what you gotta do!
/////////////////////////////////

// set the Application's backgroundColor back to it's old value
app.backgroundColor = oldColor;

I'm not familiar with using Visual FoxPro as an IDE... If you're using VBA scripting, the syntax will be a little different - but the procedure should be the same. I hope this helps.