Tuesday, March 23, 2010

formatBadParameters

I've created a very, very simple File Format Plugin named TrivialFormatPlugin which creates a 1x1 single, 8bit channel image to the photoshop host. The source code is below. The problem is that whenever I call advanceState(), I get returned an error: formatBadParameters. I have no idea why and have tried many many different settings combinations but to no avail. If anyone has any advice I would greatly appreciate it. Thank you!%26lt;br /%26gt;%26lt;br /%26gt;%26lt;code%26gt;%26lt;br /%26gt;void TrivialFormatPlugin::ReadStart(void)%26lt;br /%26gt;{%26lt;br /%26gt; formatRecord-%26gt;imageMode = plugInModeGrayScale;%26lt;br /%26gt; formatRecord-%26gt;depth = 8;%26lt;br /%26gt; formatRecord-%26gt;imageSize.h = static_cast%26lt;short%26gt;( 1 );%26lt;br /%26gt; formatRecord-%26gt;imageSize.v = static_cast%26lt;short%26gt;( 1 );%26lt;br /%26gt; formatRecord-%26gt;planes = static_cast%26lt;int16%26gt;( 1 );%26lt;br /%26gt; %26lt;br /%26gt; //read whole image in at once%26lt;br /%26gt; uint32 bufferSize = static_cast%26lt;uint32%26gt;( 1 );%26lt;br /%26gt; BufferID bufferId;%26lt;br /%26gt; OSErr allocationStatus = %26lt;br /%26gt; formatRecord-%26gt;bufferProcs-%26gt;allocateProc( bufferSize, %26amp;bufferId );%26lt;br /%26gt; Ptr dataBuffer = formatRecord-%26gt;bufferProcs-%26gt;lockProc( bufferId, false );%26lt;br /%26gt; dataBuffer[0] = 127;%26lt;br /%26gt; formatRecord-%26gt;data = dataBuffer;%26lt;br /%26gt; OSErr hostErr = formatRecord-%26gt;advanceState();%26lt;br /%26gt; if( hostErr != noErr ) {%26lt;br /%26gt; LOG_DEBUG %26lt;%26lt; ''Error returned from advanceState() call:'' %26lt;br /%26gt; %26amp;nbsp ; %26lt;%26lt; hostErr %26lt;%26lt; '' quitting.\n'';%26lt;br /%26gt; }%26lt;br /%26gt; formatRecord-%26gt;bufferProcs-%26gt;unlockProc( bufferId );%26lt;br /%26gt; formatRecord-%26gt;bufferProcs-%26gt;freeProc( bufferId );%26lt;br /%26gt; formatRecord-%26gt;data = 0;%26lt;br /%26gt;}%26lt;br /%26gt;%26lt;/code%26gt;formatBadParameters
I could help you if you were using C (much source code for format plugins in C is on
my site).
formatBadParameters
Thank you for the offer but I think I've finally figured out my problems (or at least two of the major ones):



1) Do not call advanceState() from ReadStart(). Instead use it inside ReadContinue(). I had thought the documentation was pretty clear that ReadContinue() was deprecated and that you were supposed to merge all the functionality into ReadStart(). Either the docs are wrong or I misread them.



2) theRect.bottom needs to be a greater number than theRect.top. I had these two values reversed and my images were just coming out as all white. Too bad for me that I didn't include the lines that set theRect in the code snippet I included. Perhaps someone would have caught this before I did. Oh well.



Rob
  • lips
  • No comments:

    Post a Comment