🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.photoshop.scripting
Article #2027

Draw current image with ADM

#2027
From: Barbu_Bogdan
Date: Mon, 28 Jun 2004 09:19
122 lines
4043 bytes
I want to create a photoshop automation plugin, that gets all the opened images and show them in a new dialog window. I try to use ADM functions, for dialog, images, ..., but I can not make it work; instead of drawing the current image it puts a black rectangle.
The code looks something like that:

.....
void ASAPI myDrawProc(ADMItemRef item, ADMDrawerRef inDrawer)
{

ADMImageRef imageRef = sADMImage->CreateBitmap(500,500); //this creates a copy of the current image from photoshop?
 ASPoint startPoint;

startPoint.h = 0;
 startPoint.v = 0;

sADMItem->DefaultDraw(item, inDrawer);
 sADMImage->BeginADMDrawer(imageRef);
 sADMDrawer->DrawADMImage(inDrawer, imageRef, &startPoint);
 sADMImage->EndADMDrawer(imageRef);
}

//------------------------------------------------------------------------

static ASErr ASAPI DoUIInit(ADMDialogRef dialog)
{
 ASErr error = kSPNoError;

ADMItemRef item;
 item = sADMDialog->GetItem(dialog, 14002); //14002 is the id for the PictureBox, in the dialog window
 sADMItem->SetDrawProc(item, myDrawProc);
 sADMItem->Update(item);
 return error;
}

//------------------------------------------------------------------------

SPErr DoUI ()
 {
 SPErr error = noErr;
  int item = kDNoUI; // Error value.

SaveParameters(); // Save our parameters, just in case.
 if (sADMDialog != NULL)
 {
      item = sADMDialog->Modal(gPlugInRef, "FrameSelection", 14000, kADMModalDialogStyle, DoUIInit, NULL, 0);
 }

if (item != kDOk_button)
      {
          error = 'STOP'; //'STOP' = kUserCancel;
          RestoreParameters();
      }
 return error;

}

//------------------------------------------------------------------------

DLLExport SPAPI SPErr AutoPluginMain(const char* caller, const char* selector, void* message)
{
 SPErr error = kSPNoError;
 SPMessageData * basicMessage = (SPMessageData *) message;
 sSPBasic = basicMessage->basic;
 gPlugInRef = basicMessage->self;
 if (sSPBasic->IsEqual(caller, kSPInterfaceCaller))
 {
      if (sSPBasic->IsEqual(selector, kSPInterfaceAboutSelector))
      {
           DoAbout(basicMessage->self, AboutID);
      }
 }

if (sSPBasic->IsEqual(caller, kPSPhotoshopCaller))
 {
      if (sSPBasic->IsEqual(selector, kPSDoIt))
      {
           PSActionsPlugInMessage * actionsMessage = (PSActionsPlugInMessage *) message;
           PIActionParameters * actionParams = actionsMessage->actionParameters;
          error = Execute (actionParams);
      }
 }

PIUSuitesRelease ();
     sADMBasic.Unload();
     sADMDialog.Unload();
     sADMItem.Unload();
     sADMNotify.Unload();
     sADMList.Unload();
     sADMEntry.Unload();
     sADMTrack.Unload();
     sADMDrawer.Unload();
     return error;
}

//------------------------------------------------------------------------

static SPErr Execute(PIActionParameters* actionParams)
 {
     SPErr error = kSPNoError;

Initialize();
     ReadScriptParams(actionParams);

PIDialogPlayOptions playInfo = actionParams->playInfo;

if (playInfo == plugInDialogDisplay)
     {
         error = DoUI();
     }

if (error == kSPNoError)
    {
       WriteScriptParams(actionParams);
    }
   return error;
}

//------------------------------------------------------------------------

This code works ok if instead of drawing the image, I draw a line, a rect, etc...

Can somebody tells where I do wrong?

Thanks!
Technical Details
Message-ID: <3bb4cdec.-1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news-out.ntli.net!newsrout1.ntli.net!news-in.ntli.net!ntli.net!newsfeed01.sul.t-online.de!t-online.de!webx

Show Full Headers
Complete Article Headers
X-Google-Thread: f5839,75c9142726d79d07,start
X-Google-Attributes: gidf5839,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Barbu_Bogdan@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news-out.ntli.net!newsrout1.ntli.net!news-in.ntli.net!ntli.net!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.photoshop.scripting
Subject: Draw current image with ADM
Message-ID: <3bb4cdec.-1@webx.la2eafNXanI>
Date: Mon, 28 Jun 2004 02:19:37 -0700
Lines: 137
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit