Skip to main content
Known Participant
April 7, 2014
Answered

PS Custom Format Plugin - Issue Reading Files > 2GB & < 4GB

  • April 7, 2014
  • 1 reply
  • 2117 views

Is this issue fixable within our format plugin code, or is it  a photoshop limitation?

I am new to Photoshop & Photoshop Plugins.  I have reviewed the sdk photoshop documentation & searched web on this subject.

I am working with a photoshop format plugin written by my predecessor who is no longer here.

The plugin is modeled after the simpleFormat plugin.

The plugin is being used on systems running Photoshop CS6 & CC on 64bit Windows 7 with 8GB or more memory.

The plugin allows a file of our format to be opened, read and written.

--------------------------------------------------------------------------------------------------------------------------------------------------------

ISSUE:

The plugin works fine reading  files < 2GB or > 4GB.  For files between 2GB and 4GB, the call to allocate memory fails.

--------------------------------------------------------------------------------------------------------------------------------------------------------

In the plugin's PIPL structure:   the FormatMaxSize {32767, 32767} and PluginMaxSize {PlugInMaxSize { 2147483647, 2147483647 }

----------------------------------------------------------------------

In the plugin code;  the DoReadStart() method opens the file and reads the file header information.  This works fine.

Next, in the DoReadContinue() method: SPsBuffer->New(&bufferSize, buffersize) is returning NULL.     see below.

void PluginMain (const int16 selector,

                                                                         FormatRecordPtr formatParamBlock,

                                                                         intptr_t * data,

                                                                         int16 * result)

{

...

    gFormatRecord = reinterpret_cast<FormatRecordPtr>(formatParamBlock);

          gPluginRef = reinterpret_cast<SPPluginRef>(gFormatRecord->plugInRef);

          gResult = result;

          gDataHandle = data;

...



sSPBasic = ((FormatRecordPtr)formatParamBlock)->sSPBasic;

...



if (gCountResources == NULL ||

            gGetResources == NULL ||

            gAddResource == NULL ||




gFormatRecord->advanceState == NULL)


{



*gResult = errPlugInHostInsufficient;



return;


}



// new for Photoshop 8, big documents, rows and columns are now > 30000 pixels


if (gFormatRecord->HostSupports32BitCoordinates)


        gFormatRecord->PluginUsing32BitCoordinates = true;

...

}

static void DoReadPrepare()

{

     gFormatRecord->maxData = 0

}

static void DoReadContinue (void)

{

          int32 done;

          int32 total;

          int32 row;

          VPoint imageSize = GetFormatImageSize();

          /* Set up the buffer & progress variables. */

          done = 0;

          total = imageSize.v;

    Ptr pixelData        = NULL;

    Ptr rawData          = NULL;

    Ptr uncompressedData = NULL;

    int64* offsetTable   = NULL;

/* allocate the pixel buffer. */

          unsigned32 bufferSize = gFormatRecord->planes * imageSize.v * imageSize.h;

          pixelData = sPSBuffer->New( &bufferSize, bufferSize );            <======   This allocation fails for file sizes > 2GB & < 4GB.

          if (pixelData == NULL)

          {

                    *gResult = memFullErr;

                    //return;

                    if(*gResult == memFullErr) { goto ReadContinueCleanUp; }

          }

This topic has been closed for replies.
Correct answer Tom Ruark

Some examples of files that are successfully read and files that are not successfully read are shown below:

Filenames that contain "nok" as part of the name, would not open and an out of RAM error occurs.

in the ReadContinue method, shown in an earlier post on this thread.

Filenames12x12ok12x24okoknoknoknokok
hdots17280172802316023180300013276832768
vdots8640172802316023180300013276832768
hdots * vdots1492992002985984005363856005373124009000600011.074E+091.074E+09
hdots  + vdots25920345604632046360600026553665536
hdpi,vdpi1440:7201440:7201440:7201440:7201440:7201440:7201440:720
#channels4444445
#bpp2222222
compressionPackbitsPackbitsPackbitsPackbitsPackbits

fileLength(bytes)


85937768647536143650541706393621258240
filesize (MB)3567128.198.2413.716.2720.27
filesize (GB)0.3480.690.0080.0080.01340.0160.0198

1) Requesting anything above 2 gig is risky. Try to break your problem down into smaller chunks.

2) You are over flowing unsigned32. That max's out at 4 gig. Your 5 gig request is really 1 gig.

3) We have a new suite New64 that takes an unsigned64. Against point #1 but available for those that dare.

1 reply

April 7, 2014

I'm not sure what kind of file you are trying to open or what version of Photoshop you are working with. Need more information!

echeraudAuthor
Known Participant
April 7, 2014

Hi TLL,

Thanks for responding so fast ☺

In my forum discussion I have stated that:

1. this is a format plugin modeled after the simple format plugin ( the one included with the adobe photoshop sdk).

2. This format is used with CS6 & CC.

The file I am reading is my companies file format. I believe it may be a modified TIFF type format.

April 7, 2014

I just saw the forum you were posting in after I hit reply so I'm most likely out of my league here. I was curious if you are working with geospatial data, as there are existing PS plugins for working with (opening and saving-as) tif imagery bigger than 2GB...