Problems with picFrame

View: New views
11 Messages — Rating Filter:   Alert me  

Problems with picFrame

by Jon Thelin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a plugin that was written for 4D 2004 on a Mac using the 4D 2004 Plugin SDK (written in Carbon).  I need to get it working in 4D v11 Mac.  I don't have time to rewrite it in Cocoa, so I thought I would recompile it for 32-bit Universal and try it in 4D v11.  The 4D Conversion documentation says the following: "Plug-ins of version 2004 (4D or third party) are compatible with 4D v11 SQL", so I thought it would work.

I am, however, having problems with pictures in the plugin.  I pass picture parameters to the plugin to do some special processing.  A section of the code retrieves the picture's frame rectangle to work with. When running in 4D v11, the picture frame rectangle retrieved appears to be garbage.

Here is an example of the line of code that retrieves the picture frame:

vPic1 = (PicHandle)PA_GetPictureHandleParameter( params, 1, &vPic1_info );
pic1Rect = (*vPic1)->picFrame;

How do I retrieve the proper picFrame for the picture?  I need the dimensions.

Jon Thelin


Re: Problems with picFrame

by aparajita :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Here is an example of the line of code that retrieves the picture  
> frame:
>
> vPic1 = (PicHandle)PA_GetPictureHandleParameter( params, 1,  
> &vPic1_info );
> pic1Rect = (*vPic1)->picFrame;
>
> How do I retrieve the proper picFrame for the picture?  I need the
> dimensions.

v11 does not use QuickDraw (it is deprecated), so PA_Picture is no  
longer a PicHandle. To get the dimensions you have to use  
PA_ExecuteCommandByID and call the PICTURE PROPERTIES command.

PA_Variable params[3];
PA_SetPictureVariable(¶ms[0], vPic1);
PA_SetLongintVariable(¶ms[1], 0);
PA_SetLongintVariable(¶ms[2], 0);
PA_ExecuteCommandByID(457, params, 3);

long width = PA_GetLongintVariable(¶ms[1]);
long height = PA_GetLongintVariable(¶ms[2]);

Similarly, to get the size in bytes you call the 'Picture size' command.

Regards,

    Aparajita
    www.aparajitaworld.com

    "If you dare to fail, you are bound to succeed."
    - Sri Chinmoy   |   www.srichinmoy.org

**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Re: Problems with picFrame

by Jon Thelin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


The PA_ExecuteCommandByID call does not exist in the 4D 2004 Plugin SDK.  Is this a new call in the v11 SDK?  If so, how do I modify the project to use the new 4D commands and still keep the project carbon?


Jon Thelin


aparajita wrote:
>> Here is an example of the line of code that retrieves the picture  
>> frame:
>>
>> vPic1 = (PicHandle)PA_GetPictureHandleParameter( params, 1,  
>> &vPic1_info );
>> pic1Rect = (*vPic1)->picFrame;
>>
>> How do I retrieve the proper picFrame for the picture?  I need the
>> dimensions.

> v11 does not use QuickDraw (it is deprecated), so PA_Picture is no  
> longer a PicHandle. To get the dimensions you have to use  
> PA_ExecuteCommandByID and call the PICTURE PROPERTIES command.
>
> PA_Variable params[3];
> PA_SetPictureVariable(¶ms[0], vPic1);
> PA_SetLongintVariable(¶ms[1], 0);
> PA_SetLongintVariable(¶ms[2], 0);
> PA_ExecuteCommandByID(457, params, 3);
>
> long width = PA_GetLongintVariable(¶ms[1]);
> long height = PA_GetLongintVariable(¶ms[2]);

Similarly, to get the size in bytes you call the 'Picture size' command.

Re: Problems with picFrame

by aparajita :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> The PA_ExecuteCommandByID call does not exist in the 4D 2004 Plugin  
> SDK.  Is
> this a new call in the v11 SDK?  If so, how do I modify the project  
> to use
> the new 4D commands and still keep the project carbon?

The v11 SDK is still C/Carbon-based.

Regards,

    Aparajita
    www.aparajitaworld.com

    "If you dare to fail, you are bound to succeed."
    - Sri Chinmoy   |   www.srichinmoy.org

**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Re: Problems with picFrame

by MIYAKO :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

if you examine the two sets of pluginAPI.c,
you will see that the entry point for the 2004/v11 entry points are not mutually exclusive.
it is possible to hybrid the two. (David Dancy has posted a detailed message on how) 

though,I think you should replace the call with,

PA_GetPictureParameter( params, index, *pict, &info );

for simplicity.

miyako

On 2009/09/28, at 8:10, Jon Thelin wrote:



The PA_ExecuteCommandByID call does not exist in the 4D 2004 Plugin SDK.  Is
this a new call in the v11 SDK?  If so, how do I modify the project to use
the new 4D commands and still keep the project carbon?


Jon Thelin



aparajita wrote:

Here is an example of the line of code that retrieves the picture  
frame:

vPic1 = (PicHandle)PA_GetPictureHandleParameter( params, 1,  
&vPic1_info );
pic1Rect = (*vPic1)->picFrame;

How do I retrieve the proper picFrame for the picture?  I need the
dimensions.

v11 does not use QuickDraw (it is deprecated), so PA_Picture is no  
longer a PicHandle. To get the dimensions you have to use  
PA_ExecuteCommandByID and call the PICTURE PROPERTIES command.

PA_Variable params[3];
PA_SetPictureVariable(&params[0], vPic1);
PA_SetLongintVariable(&params[1], 0);
PA_SetLongintVariable(&params[2], 0);
PA_ExecuteCommandByID(457, params, 3);

long width = PA_GetLongintVariable(&params[1]);
long height = PA_GetLongintVariable(&params[2]);

Similarly, to get the size in bytes you call the 'Picture size' command.



Parent Message unknown Re: Problems with picFrame

by Jens Blomster :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hmm... I got this to work when I compiled a new, .bundle version of the
PictPdf plugin. It has been reported to work also in v11/Intel.

Since it's for a limited internal use, and since I (as per an earlier
announcement about my plugins..) am deprecated myself, I took the
liberty to do it in an unauthorized way and to still use the deprecated
QuickDraw.

- use the 4D2004 Plugin SDK, just like before
- replace the header files Flags.h, PrivateTypes.h, PublicTypes.h with
counterparts from a Plugin SDK v11 - generated project (so to get the
64-bit types right and possible to compile)
- set XCode to compile Universal.

The resulting .bundle plugin worked with both 2004 and
v11/Intel/no-Rosetta. Apparently now there was a PicHandle, since
retrieval of the picFrame now worked as before. Maybe I activated a
compatibility layer in 4Dv11 by using the old plugin entry points.

However this was a very simple plugin. Of course since this compile is
not tested or supported by 4D you risk to cause other problems. You
could try at your own risk.

Jens Blomster
**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Re: Problems with picFrame

by Jon Thelin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jens Blomster wrote...

>> - use the 4D2004 Plugin SDK, just like before
>> - replace the header files Flags.h, PrivateTypes.h, PublicTypes.h with
>> counterparts from a Plugin SDK v11 - generated project (so to get the
>> 64-bit types right and possible to compile)
>> - set XCode to compile Universal.
>>
>> The resulting .bundle plugin worked with both 2004 and
>> v11/Intel/no-Rosetta. Apparently now there was a PicHandle, since
>> retrieval of the picFrame now worked as before. Maybe I activated a
>> compatibility layer in 4Dv11 by using the old plugin entry points.

I tired this and was unable to compile without errors in 4DPluginAPI.h and 4DPluginAPI.c (over 700 errors in total).

Here is a sample of some of the errors:

4DPluginAPI.h:218: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'PA_CreateTableRef'
4DPluginAPI.h:219: error: expected ')' before 'tableRef'
4DPluginAPI.h:220: error: expected ')' before 'tableRef'
4DPluginAPI.h:341: error: expected declaration specifiers or '...' before 'PA_PictureInfo'

Jon Thelin

Parent Message unknown Re: Problems with picFrame

by Jens Blomster :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



>
> I tired this and was unable to compile without errors in 4DPluginAPI.h and
> 4DPluginAPI.c (over 700 errors in total).


Maybe I had to do some other tweak that I don't remember now. Or it
could be some simple setting. A single #define wrong will easily
generate 700 errors here.


I can mail you the entire XCode project so you can see all the settings.
I imagine you could even take the working project and paste in your c
code instead of mine. I still claim it works - it contains a routine
that takes a 4D Picture input parameter and works with its pageRect.

Do you want it? It's 2.2 MB zipped. If you have the time to play around
with this.

/jens
**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Parent Message unknown Re: Problems with picFrame

by Jens Blomster :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jon,

I was unable to send it, your mail operator is blocking mine so I have
to answer via the list.

 >(550-213.163.128.207 blocked by
 >ldap:ou=rblmx,dc=mso,dc=att,dc=net\r\n550 Blocked for abuse.  Please
 >contact the administrator of your ISP or sending mailservice.)

Below is the message. Since I can't send the attachment we must invent
another way or try another day. Mail me an ftp login somewhere? I don't
want to just post it publicly yet, I'd just like to know who has got it.

/Jens

---------------------------- the mail:


Here is the project. The plugin call PPDF PageOut handles the rect.

If you want a test and demo 4D database for it you can take it from my
website http://www.algonet.se/~blomster/tools.html. There is a demo of
PictPDF there. Contains the old .4CX variant of the plugin. I havn't
posted the .bundle version there. But the demo runs unchanged if you let
4D upgrade the database, and replace the Mac4DX folder with a Plugins
folder with the new .bundle plugin.

You will have to update the XCode project with some search paths to
folders for e.g. the built binary. Some paths point to volumes that are
mine and won't be on your computer.


Please report what came out of this, I'm curious of course!

Best regards,
jens

**********************************************************************
4D Plugins hosted by 4D, Inc.                      http://www.4D.com/

    Register for 4D Summit 2009 Today
    http://www.4D.com/summit

To Unsubscribe:                      mailto:4D-Plugins-off@...
***********************************************************************


Re: Problems with picFrame

by Jon Thelin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The pictures that I will be working with are all in PICT format originally from the 4D database.  The PICT picture is passed to the plugin, some text is drawn over on top of the picture (and/or other pictures are added to the picture), and then it is returned to 4D for displaying/printing.  I'm using Carbon QuickDraw routines to perform the alterations to the picture.  After looking through the 4D Plugin API files from the Plugin SDK v11, I'm wondering if I can extract the PICT data from the 4D picture parameter that is passed to the Plugin (it comes through as PA_Picture).  Then make the needed alterations to the picture using Carbon Quickdraw routines and then somehow bundle the PICT file back into a PA_Picture for returning.  The following snippet is not real code, but a summary of what I might do:

        PA_Picture vPA_Pic1;
        PA_Picture newPA_Pic;
        PicHandle vPic1;
        long index = 0;
        boolean foundIt;
        PA_Unistring *type;

        vPA_Pic1 = PA_GetPictureParameter( params, 1 );
       
        ... find index of 'Pict' type in vPA_Pic1 using PA_GetPictureData calls with null handle.
        ... (it should be the first one since they are PICT pictures.)

        PicHandle vPic1 = PA_NewHandle( 0 );
        type = PA_GetPictureData( vPA_Pic1, index, (PA_Handle)vPic1 )
        PA_DisposeUnistring( type );
       
        .... do any manipulating of the PicHandle here using carbon quickdraw routines.
       
       
        >>>>> how do I put the PicHandle (vPic1) back into a PA_Picture (newPA_Pic)
                   for returning? <<<<<
       
       
        PA_SetPictureParameter( params, 1, newPA_Pic );



The problem is that I don't know how to bundle my new PicHandle (PICT format) back into 4D's PA_Picture for returning.

I could be on the wrong track entirely.

Jon Thelin

Re: Problems with picFrame

by Jon Thelin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a plugin written with the 4D 2004 Plugin SDK and compiled as universal.  When I run it using 4D v11, it runs in 'compatibility mode' as noted in 4D_v11_Plugin_SDK.pdf:
    Plugins that use 4D Plugin API v11 exports now the "FourDPackex" method
    instead of "FourDPack". When 4D loads a plugin, if the new method is exported,
    4D will load the plugin as a new plugin, and will communicate with this plugin
    using only Unicode, and the new Picture format. Plugins that continue to
    export the old method will be considered as legacy plugins, and they will
    continue to work using a compatibility mode exactly like with 4D 2004. If
    for some reasons you prefere not to handle Unicode now, you can still use
    4D Plugin SDK 2004 for this purpose, plugins created will continue to work
    exactly the same way.

I am passing a Pict picture from 4D to the plugin.  it appears to behave as if it is a Qucikdraw picture (I can perform a DrawPicture with it, etc).  However, I am unable to get the picture's picframe (rectangle) to determine it's dimensions.  It doesn't appear to be formatted as a standard Quickdraw picture.  Does anyone know how I can retrieve the picture's dimensions from within the Plugin?

Jon Thelin

>
> if you examine the two sets of pluginAPI.c,
> you will see that the entry point for the 2004/v11 entry points are  
> not mutually exclusive.
> it is possible to hybrid the two. (David Dancy has posted a detailed  
> message on how)
>
> though,I think you should replace the call with,
>
> PA_GetPictureParameter( params, index, *pict, &info );
>
> for simplicity.
>
> miyako
>
> On 2009/09/28, at 8:10, Jon Thelin wrote:
>
>
>
> The PA_ExecuteCommandByID call does not exist in the 4D 2004 Plugin  
> SDK.  Is
> this a new call in the v11 SDK?  If so, how do I modify the project  
> to use
> the new 4D commands and still keep the project carbon?
>
>
> Jon Thelin
>
>
>
> aparajita wrote:
>>
>>>> Here is an example of the line of code that retrieves the picture
>>>> frame:
>>>>
>>>> vPic1 = (PicHandle)PA_GetPictureHandleParameter( params, 1,
>>>> &vPic1_info );
>>>> pic1Rect = (*vPic1)->picFrame;
>>>>
>>>> How do I retrieve the proper picFrame for the picture?  I need the
>>>> dimensions.
>>
>>> v11 does not use QuickDraw (it is deprecated), so PA_Picture is no
>>> longer a PicHandle. To get the dimensions you have to use
>>> PA_ExecuteCommandByID and call the PICTURE PROPERTIES command.
>>>
>>> PA_Variable params[3];
>>> PA_SetPictureVariable(¶ms[0], vPic1);
>>> PA_SetLongintVariable(¶ms[1], 0);
>>> PA_SetLongintVariable(¶ms[2], 0);
>>> PA_ExecuteCommandByID(457, params, 3);
>>>
>>> long width = PA_GetLongintVariable(¶ms[1]);
>>> long height = PA_GetLongintVariable(¶ms[2]);
>>
>> Similarly, to get the size in bytes you call the 'Picture size'  
>> command.
>>