KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: A utility to convert PICT images to PNG images
PRODUCT: 4D | VERSION: 13.2 | PLATFORM: Mac & Win
Published On: March 13, 2013

For developers still needing to upgrade legacy databases, databases created prior to v13, it is very possible that there are pictures in the database picture library, or loaded from external images, stored in the PICT format.

PICT is a graphics file format introduced on the original Apple Macintosh computer as its standard format for images rendered by the QuickDraw framework. It supported the interchange between Mac applications of graphics (both bitmapped and vector), in addition to some limited text support.

As Apple has modernized its OSX operating system, it has deprecated QuickDraw framework. The PICT graphic format has been dropped as the native graphics format. The Portable Network Graphics (PNG) is now the native graphics format for the Mac. 4D v12 is the last version of 4D that contains the QuickDraw framework.

The task of going through every image used in a database and converting any PICT formatted images before upgrading to v13 is no small task. To assist in the migration of databases to v13, a new command, "AP Is Picture Deprecated" has been added to the 4D Pack plugin.

Below is a utility that can be installed an run to convert every picture in a database Picture Library from PICT to PNG.

If (True)
    If (False)
    Begin SQL
    /*
    Name: UTIL_ConvertPICTs
    Path: UTIL_ConvertPICTs

    Purpose: Convert all PICT formatted images in the
    Picture Libraray to .PNG images

    The v13.2 or later 4D Pack Plugin must be installed to use this method

    */
    End SQL
    End if
    C_TEXT($MethodName_T)
    $MethodName_T:=Current method name
    //===================== Declare Variables ==================================
    //method_parameters_declarations
    //--------------------------------------------------------------------------------
    //method_wide_constants_declarations
    //--------------------------------------------------------------------------------
    //local_variable_declarations
    C_LONGINT($Ndx;$SOA;$RIS;$PictRef_L)
    C_TEXT($PictName_T)
    C_PICTURE($Pict_G)
    C_POINTER($Pict_P)
End if
//====================== Initialize and Setup ================================

ARRAY LONGINT($PictRef_aL;0)
ARRAY TEXT($PictName_aT;0)

PICTURE LIBRARY LIST($PictRef_aL;$PictName_aT)
$SOA:=Size of array($PictRef_aL)

//======================== Method Actions ==================================

If ($SOA>0)
    For ($Ndx;1;$SOA) // for each picture
      $PictRef_L:=$PictRef_aL{$Ndx}
      $PictName_T:=$PictName_aT{$Ndx}
      GET PICTURE FROM LIBRARY($PictRef_aL{$Ndx};$Pict_G)
      $Pict_P:=->$Pict_G // passage of a pointer
      If (AP Is Picture Deprecated ($Pict_P)=1) // if format is obsolete
        CONVERT PICTURE($Pict_G;".PNG") // conversion to png
        SET PICTURE TO LIBRARY($Pict_G;$PictRef_L;$PictName_T) // and storage in the library
      End if
    End for
Else
    ALERT("The picture library is empty.")
End if

//======================== Clean up and Exit =================================

Commented by Bill Weale on July 17, 2014 at 7:52 AM
Seems like a typo here:

GET PICTURE FROM LIBRARY($Pi>ctRef_aL{$Ndx};$Pict_G)

?? $Pi>ctRef_aL{$Ndx} ??