\ProvidesFile{pdftex.def}[2010/02/14 v0.04n Graphics/color for pdfTeX]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% LaTeX Colour and Graphics support for PDFTeX
%%
%% License
%% =======
%%
%% Copyright (C) 2000-2009 David Carlisle, Sebastian Rahtz, Hans Hagen,
%% Heiko Oberdiek and Martin Schr\"oder
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is
%% Heiko Oberdiek and Martin Schr\"oder.
%%
%% This work consists of the file pdftex.def.
%%
%% Usage
%% =====
%%
%% It may be used by specifying the pdftex option to any of the
%% supported packages, for example:
%%
%% \usepackage[pdftex]{graphicx}
%%
%% * pdfTeX determines the bounding box of the images by means of
%%   itself. Therefore the bounding box options should not be used.
%%   In this cases a warning is issued and viewport is used instead.
%% * Option "page" (graphicx) for selecting a page of a multipage
%%   PDF document.
%% * \pagecolor is supported. \nopagecolor disables the page color.
%% * Option "quiet" (graphicx/experimental): log messages are suppressed.
%% * Option "resolution" (graphicx/experimental): this sets
%%   \pdfimageresolution, see pdfTeX documentation.
%% * Option "print" (graphicx/experimental): specifies an alternate
%%   print image (bitmaps only), see PDF specification.
%% * pdftex.def can be used under plain-TeX with miniltx support.
%%
%% "Experimental" means that these features can change or vanish
%% in later versions.
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% History
% ...
% 2000/04/20 v0.02s:
%  * gray color model directly supported (HO).
% 2000/05/02 v0.02t:
%  * \pagecolor supported (HO).
% 2000/05/12 v0.02u:
%  * support for multipage pdf files, option `page' added (HO).
% 2000/05/31 v0.02v:
%  * Option `page' is defined at begin document,
%    if package `keyval' is loaded after `pdftex.def'.
% 2000/06/16 v0.03a:
%  * Added Heiko to author list (DPC).
% 2000/08/31 v0.03b:
%  * support for alternate print images: option `print' added (HO).
%    * This feature is not supported by Ghostscript, xpdf, or AR3.
%    * The images should have the same dimensions/resolution.
%  * Two experimental options added (HO):
%    * `quiet': log messages are suppressed.
%    * `resolution': sets \pdfimageresolution.
%    Because these options are not supported by graphicx,
%    they have to be set after \usepackage{graphicx}, eg.
%      \setkeys{Gin}{quiet,resolution=300}
%    Option `quiet' (for pdftex) can be make known to graphic{s,x}
%    with this line in graphics.cfg:
%      \DeclareOption{quiet}{\let\Gin@log\@gobble}
%    Caution: both options are experimental and can be
%    change in next versions!
%  * \pdfpage{width,height} are only set, if \paperwidth
%    is defined (HO).
% 2000/09/04 v0.03c
%  * Redefinition of `natwidth' and `natheight' \AtBeginDocument (HO).
% 2000/09/14 v0.03d
%  * Fixes for `viewport' and `trim' (HO).
%  * Clip support added for viewport and trim (HO).
% 2000/09/14 v0.03e
%  * Options `bbllx', `bblly', `bburx', `bbury' disabled,
%    option `bb' redirected with a warning to `viewport' (HO).
% 2000/11/10 v0.03f
%  * Bug, that produces an error message, if package `graphics'
%    is used (introduced in 0.03d), fixed: If \Gin@vllx is not
%    defined (graphics), then clipping and the moves of options
%    viewport/trim are silently disabled (HO).
% 2001/05/25 v0.03g
%  * \pdfpagewidth and \pdfpageheight are not set to zero,
%    if \paperwidth and \paperheight are not set (HO).
% 2001/09/01 v0.03h
%  * Compatibilty for miniltx.tex, problems fixed:
%    \@ifpackageloaded, \PackageWarning, \PackageWarningNoLine,
%    \@currname.
% 2001/11/29 v0.03i
%  * Problem with \if@inlabel (plain format) fixed.
% 2002/06/18 v0.03j
%  * Contribution by P\'etiard Fran\c{c}ois <petiard@math.univ-fcomte.fr>:
%    Improvement of \Ginclude@mps (support of viewport and clip).
% 2002/06/19 v0.03k
%  * Correction by P\'etiard Fran\c{c}ois for \GPT@DoEndClip.
% 2005/06/15 v0.03l
%  * \usebox patch fixed (\aftergroup part removed) (HO).
% 2005/06/20 v0.03m
%  * .tif support is removed for pdfTeX >= 1.10a (HO).
% 2006/02/23 v0.03n
%  * Compatibility for plain-TeX: file can be loaded multiple times;
%    colorfix is not applied for undefined macros (HO).
% 2006/02/24 v0.03o
%  * Catcode protections mainly because of babel's shorthands (HO).
% 2006/03/02 v0.03p
%  * \pagecolor support for plain-TeX fixed (HO).
% 2006/05/17 v0.03q
%  * Error message if ConTeXt's supp-pdf.tex is missing and
%    support of MPS files is not available (Markus Kohm = MK, HO).
% 2006/06/06 v0.03r
%  * \nopagecolor/\no@page@color added (HO).
% 2006/07/16 v0.03s (HO)
%  * LPPL 1.3c.
%  * A little usage.
%  * Test for \MessageBreak changed (comp.text.tex,
%    message id: <44baca88$0$10529$9b4e6d93@newsread4.arcor-online.net>).
% 2006/08/14 v0.03t (HO)
%  * Extensions added: .jpeg, .JPG, .JPEG, .PNG, .PDF
%    No variants for .tif, because TIFF support is no longer available.
%    No need for uppercase variant of .mps.
% 2007/01/01 v0.04a (HO)
%  * Support of color stack, introduced in pdfTeX 1.40.0.
%  * Support of transform matrix commands of pdfTeX 1.40.0.
%  * The argument for option `page' can be a register.
% 2007/01/02 v0.04b (HO)
%  * Internal change: Switching of color stacks is easier by using
%    \@pdfcolorstack for the stack number. Thus this command
%    should be redefined, if someone wants to use another color stack
%    (e.g. for footnotes). \main@pdfcolorstack should not be changed
%    for this purpose.
% 2007/01/06 v0.04c (HO)
%  * Support for JBIG2 added (pdfTeX 1.40.0).
% 2007/01/08 v0.04d (HO)
%  * Bug fix: .mps forgotten for extension list if pdfTeX >= 1.40.0
%  * .jbig2 and .jb2 are not listed in the extension list
%    if \pdfminorversion < 4. Thus \pdfminorversion should have
%    the correct value, if pdftex.def is loaded.
% 2007/03/15 v0.04e (HO)
%  * Missing comma in \Gin@extensions added (found by Reinhard Kotucha).
% 2007/04/06 v0.04f (HO)
%  * Fix for \pagecolor, text before page color can lead to an invalid
%    page stream. Therefore "page" is now used instead of "direct"
%    as modifier for \pdfliteral.
%  * Boolean option `resetcolor' added (pdfTeX >= 0.12n).
%    The current color is used for PDF or MPS images, unless
%    the images contain their own color settings.
%    If option `resetcolor' is set to `true', then the current color
%    is reset to \normalcolor during image inclusion.
% 2007/04/17 v0.04g (HO)
%  * Small improvement of robustness of \pagecolor
%    and using e-TeX if available.
% 2007/06/12 v0.04h (HO)
%  * Fix for \pagecolor: v0.04f uses keyword `page' for \pdfliteral,
%    but this keyword is not available before pdfTeX 1.30.0.
% 2007/12/04 v0.04i (HO)
%  * Fatal error is avoided if image file does not exists.
% 2007/12/06 v0.04j (HO)
%  * Option xmpfile added for adding metadata (experimental).
% 2008/07/16 v0.04k (HO)
%  * \LoadMetaPostSpecialExtensions
%    loads additional support for MetaPost images (transparency)
%    by loading supp-mpe.tex and supp-mis.tex
%    (method posted in comp.text.tex by Jeremy Lea).
%    As side effect MetaPost images are put in separate objects
%    and are not inlined in the page stream.
%    Status: experimental.
% 2008/09/08 v0.04l (HO)
%  * Adds an error message, if pdfTeX is called in DVI mode.
%  * Aborts loading of the package with an error message,
%    if pdfTeX is missing.
% 2009/08/25 v0.04m (HO)
%  * Catcodes are preserved and initialized for loading of
%    pdftex.def and ConTeXt's support files.
%  * ConTeXt's support files have now the extension `.mkii' instead
%    of `.tex'.
% 2010/02/14 v0.04n (HO)
%  * \GPT@catcodes extended for xmlTeX (pdftex.def loads
%    supp-pdf.mkii at begin document where xmlTeX's catcodes
%    are already active).
%
% Prefix of internal commands for this file `pdftex.def':
%   \GPT@ (Graphics bundle PdfTex driver)

\expandafter\edef\csname GPT@endinput\endcsname{%
  \expandafter\noexpand\csname GPT@restore@\endcsname
  \catcode35 \the\catcode35\relax % #
  \catcode64 \the\catcode64\relax % @
  \noexpand\endinput
}
\catcode35 6 % #
\catcode64 11 % @
\def\GPT@catcodes#1{%
  \expandafter\edef\csname GPT@restore@#1\endcsname{%
    \endlinechar \the\endlinechar
    \catcode9 \the\catcode9 % tab
    \catcode13 \the\catcode13 % ^^M
    \catcode32 \the\catcode32 % space
    \catcode33 \the\catcode33 % !
    \catcode34 \the\catcode34 % "
    \catcode35 \the\catcode35 % #
    \catcode36 \the\catcode36 % $
    \catcode37 \the\catcode37 % %
    \catcode38 \the\catcode38 % &
    \catcode39 \the\catcode39 % '
    \catcode40 \the\catcode40 % (
    \catcode41 \the\catcode41 % )
    \catcode42 \the\catcode42 % *
    \catcode43 \the\catcode43 % +
    \catcode44 \the\catcode44 % ,
    \catcode45 \the\catcode45 % -
    \catcode46 \the\catcode46 % .
    \catcode47 \the\catcode47 % /
    \catcode58 \the\catcode58 % :
    \catcode59 \the\catcode59 % ;
    \catcode60 \the\catcode60 % <
    \catcode61 \the\catcode61 % =
    \catcode62 \the\catcode62 % >
    \catcode63 \the\catcode63 % ?
    \catcode64 \the\catcode64 % @
    \catcode91 \the\catcode91 % [
    \catcode92 \the\catcode92 % \
    \catcode93 \the\catcode93 % ]
    \catcode94 \the\catcode94 % ^
    \catcode95 \the\catcode95 % _
    \catcode96 \the\catcode96 % `
    \catcode123 \the\catcode123 % {
    \catcode124 \the\catcode124 % |
    \catcode125 \the\catcode125 % }
    \catcode126 \the\catcode126 % ~
  }%
  \endlinechar 13 %
  \catcode9 10 % tab
  \catcode13 5 % ^^M (end of line)
  \catcode64 11 %
  \catcode61 12 % =
  \catcode32 10 % space
  \catcode33 12 % !
  \catcode34 12 % "
  \catcode35 6 % #
  \catcode36 3 % $
  \catcode37 14 % %
  \catcode38 4 % &
  \catcode39 12 % '
  \catcode40 12 % (
  \catcode41 12 % )
  \catcode42 12 % *
  \catcode43 12 % +
  \catcode44 12 % ,
  \catcode45 12 % -
  \catcode46 12 % .
  \catcode47 12 % /
  \catcode58 12 % :
  \catcode59 12 % ;
  \catcode60 12 % <
  \catcode61 12 % =
  \catcode62 12 % >
  \catcode63 12 % ?
  \catcode64 11 % @
  \catcode91 12 % [
  \catcode92 0 % \
  \catcode93 12 % ]
  \catcode94 7 % ^
  \catcode95 8 % _
  \catcode96 12 % `
  \catcode123 1 % {
  \catcode124 12 % |
  \catcode125 2 % }
  \catcode126 13 % ~
}
\GPT@catcodes{}

\ifx\pdftexversion\@undefined
  \def\driver@release{1}%
\else
  \ifnum\pdftexversion<12 %
    \def\driver@release{2}%
  \else
    \ifnum\pdftexversion<13 %
      \ifnum\expandafter`\pdftexrevision<`n %
        \def\driver@release{3}%
      \else
        \def\driver@release{4}%
      \fi
    \else
      \ifnum\pdftexversion=13 %
        \def\driver@release{5}%
      \else
        \ifnum\pdftexversion=14 %
          \def\driver@release{6}%
        \else
          \ifnum\pdftexversion<110 %
            \def\driver@release{7}%
          \else
            \ifnum\pdftexversion<130 %
              % 1.30.0 adds keyword `page' for \pdfliteral
              \def\driver@release{8}%
            \else
              \ifnum\pdftexversion<140 %
                % .tif support was dropped in pdfTeX 1.10a
                \def\driver@release{9}%
              \else
                % JBIG2 support added in pdfTeX 1.40.0
                \def\driver@release{10}%
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
\fi

% miniltx.tex does not define \PackageWarning, \PackageWarningNoLine, ...
\@ifundefined{PackageWarning}{%
  \def\PackageWarning#1#2{%
    \begingroup
      \newlinechar=10 %
      \def\MessageBreak{%
        ^^J(#1)\@spaces\@spaces\@spaces\@spaces
      }%
      \immediate\write16{^^JPackage #1 Warning: #2\on@line.^^J}%
    \endgroup
  }%
}{}
\@ifundefined{PackageWarningNoLine}{%
  \def\PackageWarningNoLine#1#2{%
    \PackageWarning{#1}{#2\@gobble}%
  }%
}{}
\@ifundefined{on@line}{%
  \def\on@line{ on input line \the\inputlineno}%
}{}
\@ifundefined{@spaces}{%
  \def\@spaces{\space\space\space\space}%
}{}
\@ifundefined{@ehc}{%
  \def\@ehc{%
    Try typing \space <return> %
    \space to proceed.\MessageBreak
    If that doesn't work, type \space X <return> \space to quit.%
  }%
}{}
% LaTeX defines \MessageBreak=\relax outside messages
\ifx\MessageBreak\@undefined
  \def\GPT@error#1#2{%
    \begingroup
      \newlinechar=10\relax
      \def\MessageBreak{^^J}%
      \edef\x{%
        \PackageError{pdftex.def}{#1}{#2}%
      }%
      \x
    \endgroup
  }%
\else
  \def\GPT@error{\PackageError{pdftex.def}}%
\fi
\def\GPT@warn{\PackageWarning{pdftex.def}}%
\ifx\Gin@log\@undefined
  \def\Gin@log{\message}%
\fi

% Are we running under PDFTeX?
\ifx\pdftexversion\@undefined
  \GPT@error{%
    Option `pdftex' requires pdfTeX,\MessageBreak
    but pdfTeX features are missing.\MessageBreak
    Loading of this driver file is aborted%
  }\@ehc
  \expandafter\GPT@endinput
\else
  \ifx\paperwidth\@undefined
  \else
    \ifdim\paperheight=0pt\relax
    \else
      \pdfpageheight\paperheight
    \fi
    \ifdim\paperwidth=0pt\relax
    \else
      \pdfpagewidth\paperwidth
    \fi
  \fi
  \ifnum\pdfoutput<1 %
    \GPT@error{%
      PDF mode expected, but DVI mode detected!\MessageBreak
      If you are using `latex', then call `pdflatex'.\MessageBreak
      Otherwise check and  correct the driver options.\MessageBreak
      Error recovery by switching to PDF mode%
    }\@ehc
    \pdfoutput=1 %
  \fi
\fi

% Colour Support. The following models may be used.
%   * cmyk   supported directly.
%   * rgb    supported directly.
%   * RGB    converted to rgb by this file.
%   * gray   supported directly.
%   * named  converted to cmyk by this file.
%
\def\c@lor@arg#1{%
  \dimen@#1\p@
  \ifdim\dimen@<\z@\dimen@\maxdimen\fi
  \ifdim\dimen@>\p@
    \PackageError{color}{Argument `#1' not in range [0,1]}\@ehd
  \fi
}
\def\color@cmyk#1#2{\c@lor@@cmyk#2\@@#1}
\def\c@lor@@cmyk#1,#2,#3,#4\@@#5{%
  \c@lor@arg{#4}%
  \c@lor@arg{#1}%
  \c@lor@arg{#2}%
  \c@lor@arg{#3}%
  \edef#5{#1 #2 #3 #4 k #1 #2 #3 #4 K}%
}
\def\color@gray#1#2{%
  \c@lor@arg{#2}%
  \edef#1{#2 g #2 G}%
}
\def\color@rgb#1#2{\c@lor@@rgb#2\@@#1}
\def\c@lor@@rgb#1,#2,#3\@@#4{%
  \c@lor@arg{#1}%
  \c@lor@arg{#2}%
  \c@lor@arg{#3}%
  \edef#4{#1 #2 #3 rg #1 #2 #3 RG}%
}
\def\color@RGB#1#2{\c@lor@@RGB#2\@@#1}
\def\c@lor@@RGB#1,#2,#3\@@#4{%
  \c@lor@RGB@rgb{#1}\@tempa
  \c@lor@RGB@rgb{#2}\@tempb
  \c@lor@RGB@rgb{#3}\@tempc
  \c@lor@@rgb\@tempa,\@tempb,\@tempc\@@#4%
}
\def\c@lor@RGB@rgb#1#2{%
  \dimen@#1\p@
  \divide\dimen@\@cclv
  \edef#2{\strip@pt\dimen@}%
}

\def\color@named#1#2{\c@lor@@named#2,,\@@#1}
\def\c@lor@@named#1,#2,#3\@@#4{%
  \@ifundefined{col@#1}{%
    \PackageError{color}{Undefined color `#1'}\@ehd
  }{%
    \edef#4{\csname col@#1\endcsname}%
  }%
}

\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname pdfcolorstack\endcsname\relax
  \def\set@color{%
    \pdfliteral{\current@color}%
    \aftergroup\reset@color
  }%
  \def\reset@color{%
    \pdfliteral{\current@color}%
  }%
\else
  \chardef\main@pdfcolorstack=0 %
  \@ifundefined{@pdfcolorstack}{%
    \def\@pdfcolorstack{\main@pdfcolorstack}%
  }{}%
  \def\set@color{%
    \pdfcolorstack\@pdfcolorstack push{\current@color}%
    \aftergroup\reset@color
  }%
  \def\reset@color{%
    \pdfcolorstack\@pdfcolorstack pop\relax
  }%
\fi
\def\define@color@named#1#2{%
  \expandafter\edef\csname col@#1\endcsname{#2}%
}
\def\current@color{0 g 0 G}

% v0.02t: support for \pagecolor
% fixed in v0.02p by using a box register, see
% http://tug.org/pipermail/pdftex/2005-August/005916.html
%
% v0.03r: \nopagecolor/\no@page@color added.
\newif\ifGPT@pagecolor
\@ifundefined{nopagecolor}{%
  \def\nopagecolor{\no@page@color}%
}{}
\def\no@page@color{%
  \global\GPT@pagecolorfalse
}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname currentgrouplevel\endcsname\relax
  \catcode`X=9  % ignore
  \catcode`E=14 % comment
\else
  \catcode`X=14 % comment
  \catcode`E=9  % ignore
\fi
\def\set@page@color{%
  \global\GPT@pagecolortrue
  \global\let\current@page@color\current@color
  \@ifundefined{GPT@outputbox}{%
    % \newbox is outer in plain
    \csname newbox\endcsname\GPT@outputbox
  }{}%
  \@ifundefined{GPTorg@shipout}{%
    \global\let\GPTorg@shipout\shipout
    \gdef\shipout{%
X     % ensure \GPT@outputbox is really void
X     \begingroup
X       \setbox\GPT@outputbox=\box\GPT@outputbox
X     \endgroup
E     \edef\GPT@saved@grouplevel{\number\currentgrouplevel}%
      \afterassignment\GPT@shipout
      \global\setbox\GPT@outputbox=%
    }%
    \gdef\GPT@shipout{%
X     \ifvoid\GPT@outputbox\relax
E     \ifnum\GPT@saved@grouplevel=\currentgrouplevel
E     \else
        \expandafter\aftergroup
      \fi
      \GPT@@shipout
    }%
    \gdef\GPT@@shipout{%
      \ifvoid\GPT@outputbox\relax
        \GPT@warn{Ignoring void output box}%
      \else
        \setbox\GPT@outputbox=\vbox{%
          \GPT@pageliteral
          \box\GPT@outputbox
        }%
        \GPTorg@shipout\box\GPT@outputbox\relax
      \fi
    }%
    \gdef\GPT@pageliteral{%
      \ifGPT@pagecolor
        \pdfliteral\ifnum\driver@release>8 page\else direct\fi{%
          q % gsave
          \current@page@color\space
          n % newpath
          0 0 \strip@pt\pdfpagewidth\space
          \strip@pt\pdfpageheight\space re % rectangle
          % there is no need to convert to bp
          f % fill
          Q% grestore
        }%
      \fi
    }%
  }{}%
}
\catcode`\X=11 %
\catcode`\E=11 %

% Need the `colorfix' modifications as no internal colour stack
% is maintained
%<*colorfix>
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname pdfcolorstack\endcsname\relax
  \AtBeginDocument{%
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname color\endcsname\relax
      % Without color we don't need any fixes.
    \else
      \@ifundefined{@ldc@l@r}{%
        \let\@ldc@l@r\color
        \def\color{%
          \@ifundefined{if@inlabel}{}{%
            \csname if@inlabel\expandafter\endcsname
            \expandafter\leavevmode\csname fi\endcsname
          }%
          \@ldc@l@r
        }%
      }{}%
      \@ifundefined{@lduseb@x}{%
        \begingroup\expandafter\expandafter\expandafter\endgroup
        \expandafter\ifx\csname usebox\endcsname\relax
        \else
          \let\@lduseb@x\usebox
          \def\usebox#1{\@lduseb@x{#1}\reset@color}%
        \fi
      }{}%
    \fi
  }%
\fi
%</colorfix>

%
% Graphic inclusion. Currently supports .png, .jpg, .mps and .pdf inclusion;
% .tif support is dropped since pdfTeX 1.10a.
% .mps is MetaPost output.
% .mps inclusion depends on loading a CONTEXT module by Hans Hagen;
% .pdf also needs a Context module unless pdftex 0.12n or later.
%
% PNG bitmaps may be scaled/rotated as usual
% by the graphics commands or keyword arguments.
%
% Note the magic in front of the file name after \pdfimage, to
% prevent it fouling up with file names starting with "depth".
\def\Gread@png{%
  \GPT@read\Gread@@png
}
\def\Gread@@png#1{%
  \setbox\@tempboxa\hbox{%
    \pdfimage\noexpand\noexpand\noexpand\@empty#1\relax
  }%
  \def\Gin@llx{0}\let\Gin@lly\Gin@llx
  \Gin@defaultbp\Gin@urx{\wd\@tempboxa}%
  \Gin@defaultbp\Gin@ury{\ht\@tempboxa}%
}

%
% support for
% * multipage pdf images (pdfTeX v0.14+)
% * alternate print image (bitmaps only)
%   * driver version>=5 (0.14)
%   * printed image can be resused, but not the base image,
%     because it's dictionary contains the additional key /Alternates.
%   * not supported by Ghostscript or xpdf.
% * option quiet
% * option resetcolor
% * option xmpfile
%
% \GPT@page: page number of pdf image or \@empty otherwise.
\let\GPT@page\@empty
% \GPT@print: file name for alternate image or \@empty otherwise.
\let\GPT@print\@empty
\let\GPT@xmpfile\@empty
\newif\ifGPT@ResetColor
\let\GPT@ResetColorEnd\relax
\def\GPT@ResetColorBegin{%
  \ifGPT@ResetColor
    \ifGPT@IsBitmap
    \else
      \begingroup
      \normalcolor
      \let\GPT@ResetColorEnd\endgroup
    \fi
  \fi
}
\begingroup
  \toks@{%
    \define@key{Gin}{resetcolor}[true]{%
      \csname GPT@ResetColor%
        \expandafter\ifx\csname iftrue\expandafter\endcsname
                        \csname if#1\endcsname
          true%
        \else
          false%
        \fi
      \endcsname
    }%
    \ifnum\driver@release>5 %
      \define@key{Gin}{page}{%
        \def\GPT@page{#1}%
        \ifx\GPT@page\@empty
        \else
          \edef\GPT@page{\number\GPT@page}%
        \fi
      }%
      \define@key{Gin}{print}{%
        \def\GPT@print{#1}%
      }%
    \else
      \define@key{Gin}{page}{%
        \GPT@warn{%
          pdfTeX >= 0.14 required for option\MessageBreak `page'%
        }%
      }%
      \define@key{Gin}{print}{%
        \GPT@warn{%
          pdfTeX >= 0.14 required for option\MessageBreak `print'%
        }%
      }%
    \fi
    \define@key{Gin}{quiet}[]{%
      \let\Gin@log\@gobble
    }%
    \define@key{Gin}{resolution}{%
      \pdfimageresolution#1\relax
    }%
    \define@key{Gin}{xmpfile}[\Gin@base.xmp]{%
      \def\GPT@xmpfile{#1}%
    }%
  }%
  \@ifundefined{define@key}{%
    \edef\x{\endgroup
      \noexpand\AtBeginDocument{%
        \noexpand\@ifundefined{define@key}{}{\the\toks@}%
      }%
    }\x
  }{%
    \expandafter\endgroup\the\toks@
  }%

% redefinitions of some graphicx options:
\def\GPT@disable#1{%
  \GPT@warn{%
    Option `#1' is not supported, use\MessageBreak
    option `viewport' instead%
  }%
}
\def\GPT@fix{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname define@key\endcsname\relax
  \else
    \def\KV@Gin@bb{%
      \GPT@warn{%
        Option `bb' does not make sense,\MessageBreak
        using `viewport' instead%
      }%
      \KV@Gin@viewport
    }%
    \define@key{Gin}{bbllx}{\GPT@disable{bbllx}}%
    \define@key{Gin}{bblly}{\GPT@disable{bblly}}%
    \define@key{Gin}{bburx}{\GPT@disable{bburx}}%
    \define@key{Gin}{bbury}{\GPT@disable{bbury}}%
  \fi
}
\AtBeginDocument{\GPT@fix}

%
% Check for image file existence
%
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname pdffilesize\endcsname\relax
  \ifnum\driver@release>9 %
    \RequirePackage{pdftexcmds}\relax
  \fi
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname pdf@filesize\endcsname\relax
    \def\GPT@IfFileExists#1{%
      \IfFileExists{#1}%
    }%
  \else
    \def\GPT@IfFileExists#1{%
      \expandafter\expandafter\expandafter\ifx
      \expandafter\expandafter\expandafter\relax\pdf@filesize{#1}\relax
        \expandafter\@secondoftwo
      \else
        \expandafter\@firstoftwo
      \fi
    }%
  \fi
\else
  \def\GPT@IfFileExists#1{%
    \expandafter\ifx\expandafter\relax\pdffilesize{#1}\relax
      \expandafter\@secondoftwo
    \else
      \expandafter\@firstoftwo
    \fi
  }%
\fi

%
% Wrapper for \Gread@... that checks image existence first.
%
\def\GPT@read#1#2{%
  \GPT@IfFileExists{#2}%
  {%
    #1{#2}%
  }{%
    \def\Gin@llx{0}%
    \let\Gin@lly\Gin@llx
    \def\Gin@urx{72}%
    \let\Gin@ury\Gin@urx
    \ifGin@draft
    \else
      \GPT@error{File `#2' not found}{%
        Using draft setting for this image.\MessageBreak
        \@ehc
      }%
      \Gin@drafttrue
    \fi
  }%
}

%
% mechanism for re-use of objects also
% allows us to get the size by deriving it from the initial storage;
% this works for all graphics types.
%
\@ifundefined{Gread@gobject}{%
  \csname newcount\endcsname\Gread@gobject
}{}
\def\GPT@ReusedName#1{%
  \ifx\GPT@print\@empty
    #1%
  \else
    \GPT@print
  \fi
}
\def\Gread@pdftex{%
  \GPT@read\Gread@@pdftex
}
\def\Gread@@pdftex#1{%
  % Ensure that option `print' works only on bitmap images.
  \ifGPT@IsBitmap
  \else
    \ifx\GPT@print\@empty
    \else
      \GPT@warn{%
        Option `print' can only be used\MessageBreak
        for bitmap images%
      }%
      \let\GPT@print\@empty
    \fi
  \fi
  % Check if print image exists.
  \ifx\GPT@print\@empty
  \else
    \GPT@IfFileExists{\GPT@print}{%
    }{%
      \GPT@error{Print image `\GPT@print' not found}{%
        The print version of the image is ignored.\MessageBreak
        \@ehc
      }%
      \let\GPT@print\@empty
    }%
  \fi
  % If option `print' is set, the screen image object
  % will contain an additional /Alternate entry
  % and will therefore not be reused.
  \ifx\GPT@print\@empty
  \else
    \expandafter\expandafter\expandafter\@firstoftwo\expandafter\@gobbletwo
  \fi
  \@ifundefined{#1 image\GPT@page}{%
    \ifnum\driver@release>4 %
      \ifnum\driver@release>5 %
        \let\GPT@Attr\@empty
        \ifx\GPT@xmpfile\@empty
        \else
          \@ifundefined{GPT@XMP@\GPT@xmpfile}{%
            \GPT@IfFileExists{\GPT@xmpfile}{%
              \begingroup
                \pdfcompresslevel=0 %
                \immediate\pdfobj stream attr{%
                  /Type/Metadata%
                  /Subtype/XML%
                }file{\GPT@xmpfile}%
                \expandafter\xdef\csname GPT@XMP@\GPT@xmpfile\endcsname{%
                  \the\pdflastobj
                }%
              \endgroup
            }{%
              \GPT@warn{Missing XMP file (\GPT@xmpfile)}%
            }%
          }{}%
          \edef\GPT@Attr{/Metadata \@nameuse{GPT@XMP@\GPT@xmpfile} 0 R}%
        \fi
        \ifx\GPT@print\@empty
          \ifx\GPT@Attr\@empty
            \let\GPT@RuleAttr\@empty
          \else
            \edef\GPT@RuleAttr{attr{\GPT@Attr}}%
          \fi
        \else
          \@ifundefined{\GPT@print\space image\GPT@page}{%
            \immediate\pdfximage{\GPT@print}%
            \setbox\@tempboxa=\hbox{\pdfrefximage\pdflastximage}%
            \edef\GPT@PrintObj{\the\pdflastximage}%
            \expandafter\xdef\csname\GPT@print\space
              image\GPT@page\endcsname{\pdfrefximage\GPT@PrintObj}%
            \immediate\pdfobj{%
              [<<%
                /Image \GPT@PrintObj\space 0 R%
                /DefaultForPrinting true%
              >>]%
            }%
            \def\GPT@RuleAttr{%
              width\wd\@tempboxa height\ht\@tempboxa
              attr{%
                \GPT@Attr
                /Alternates \the\pdflastobj\space 0 R%
              }%
            }%
          }{%
            \edef\GPT@PrintObj{%
              \expandafter\expandafter\expandafter\@gobble
              \csname\GPT@print\space image\GPT@page\endcsname
            }%
            \immediate\pdfobj{%
              [<<%
                /Image \GPT@PrintObj \space 0 R%
                /DefaultForPrinting true%
              >>]%
            }%
            \def\GPT@RuleAttr{%
              width \csname\GPT@print\space width\GPT@page\endcsname
              height \csname\GPT@print\space height\GPT@page\endcsname
              attr{%
                \GPT@Attr
                /Alternates \the\pdflastobj\space 0 R%
              }%
            }%
          }%
        \fi
        \pdfximage\GPT@RuleAttr
        \ifx\GPT@page\@empty
        \else
          page \GPT@page
        \fi
        {#1}%
        \setbox\@tempboxa=\hbox{\pdfrefximage\pdflastximage}%
      \else
        \setbox\@tempboxa=\hbox{\pdfimage{#1}}%
      \fi
    \else
      \setbox\@tempboxa=\hbox{%
        \pdfimage\noexpand\noexpand\noexpand\@empty#1\relax
      }%
    \fi
    \def\Gin@llx{0}\let\Gin@lly\Gin@llx
    \Gin@defaultbp\Gin@urx{\wd\@tempboxa}%
    \Gin@defaultbp\Gin@ury{\ht\@tempboxa}%
    \expandafter\xdef\csname\GPT@ReusedName{#1} width\GPT@page\endcsname{%
      \the\wd\@tempboxa
    }%
    \expandafter\xdef\csname\GPT@ReusedName{#1} height\GPT@page\endcsname{%
      \the\ht\@tempboxa
    }%
    \ifnum\driver@release>5 %
      \expandafter\xdef\csname #1 image\GPT@page
        \ifx\GPT@print\@empty\else!\fi\endcsname{%
        \pdfrefximage\the\pdflastximage
      }%
    \else
      \pdfform\@tempboxa
      \Gread@gobject=\pdflastform
      \expandafter\xdef\csname#1 image\endcsname{%
        \pdfrefform\the\Gread@gobject
      }%
    \fi
    \Gin@log{%
       <#1, id=%
       \ifnum\driver@release>5 %
         \the\pdflastximage
         \ifx\GPT@page\@empty\else , page=\GPT@page\fi
         \ifx\GPT@print\@empty
         \else
            , print=\GPT@print, id=\GPT@PrintObj
         \fi
       \else
         \the\Gread@gobject
       \fi
       , \the\wd\@tempboxa\space x \the\ht\@tempboxa
       >%
     }%
  }{%
    \def\Gin@llx{0}\let\Gin@lly\Gin@llx
    \Gin@defaultbp\Gin@urx{\csname#1 width\GPT@page\endcsname}%
    \Gin@defaultbp\Gin@ury{\csname#1 height\GPT@page\endcsname}%
  }%
}
\def\Ginclude@pdftex#1{%
  \def\@tempa{!}%
  \ifx\Gin@scaley\@tempa
    \let\Gin@scaley\Gin@scalex
  \else
    \ifx\Gin@scalex\@tempa\let\Gin@scalex\Gin@scaley\fi
  \fi
  \Gin@log{%
    <use #1%
    \ifx\GPT@page\@empty\else, page \GPT@page\fi
    >%
  }%
  \hbox{%
    \GPT@ResetColorBegin
    \Gscale@box{\Gin@scalex}[\Gin@scaley]{%
      \@ifundefined{Gin@vllx}{%
        \GPT@viewportfalse
        % without viewport/trim clipping does not make sense
        % for pdfTeX
        \Gin@clipfalse
      }{}%
      \ifGin@clip
        \ifnum\driver@release<6 %
          \GPT@warn{No clipping support in pdfTeX < 0.14}%
        \else
          \if!\Gin@vllx\Gin@vlly\Gin@vurx\Gin@vury!%
          \else
            \let\GPT@clipend\GPT@DoClipEnd
            \setbox\@tempboxa\hbox\bgroup
          \fi
        \fi
      \fi
      \ifGPT@viewport
        \ifdim\Gin@vlly\p@=\z@
        \else
          \lower\Gin@vlly bp\hbox\bgroup
        \fi
        \ifdim\Gin@vllx\p@=\z@
        \else
          \hskip-\Gin@vllx bp\relax
        \fi
      \fi
      \csname#1 image\GPT@page
        \ifx\GPT@print\@empty\else!\fi
      \endcsname
      \ifGPT@viewport
        \ifdim\Gin@vlly\p@=\z@
        \else
          \egroup
        \fi
        \GPT@clipend
      \fi
    }%
    \GPT@ResetColorEnd
  }%
}
\newif\ifGPT@viewport
\GPT@viewporttrue
\let\GPT@clipend\relax
\def\GPT@DoClipEnd{%
  \egroup
  \dp\@tempboxa\z@
  % \Gin@urx and \Gin@ury already contain the correct values,
  % so both cases viewport and trim can be handled together:
  \dimen@\Gin@urx\p@
  % v0.03k \Gin@vllx replaced by \Gin@llx
  \advance\dimen@ -\Gin@llx\p@
  \wd\@tempboxa\strip@pt\dimen@ bp\relax
  \dimen@\Gin@ury\p@
  % v0.03k \Gin@vlly replaced by \Gin@lly
  \advance\dimen@ -\Gin@lly\p@
  \ht\@tempboxa\strip@pt\dimen@ bp\relax
  \pdfxform\@tempboxa
  \pdfrefxform\pdflastxform
}
\newif\ifGPT@IsBitmap
\def\Gread@pdfbitmap#1{%
  \GPT@IsBitmaptrue
  \Gread@pdftex{#1}%
  \GPT@IsBitmapfalse
}

\edef\Gread@MBox{/MediaBox}
\def\Gread@pdf{%
  \GPT@read\Gread@@pdf
}
\def\Gread@@pdf#1{%
  \begingroup
    \@tempcnta\z@
    \loop
    \ifnum\@tempcnta<\@xxxii
      \catcode\@tempcnta14 %
      \advance\@tempcnta\@ne
    \repeat
    \catcode127=14 %
    \let\do\@makeother\dospecials\catcode`\ 10 %
    \catcode\endlinechar5 %
    \immediate\openin\@inputcheck#1 %
    \ifeof\@inputcheck
      \@latex@error{File `#1' not found}\@ehc
    \else
      \Gread@true
      \let\@tempb\Gread@false
      \loop
% v0.02e: use \. not \@tempa so the space is preserved before [
        \read\@inputcheck to\.%
        \ifeof\@inputcheck
          \Gread@false
        \else
          \expandafter\Gread@find@mbox\. []\\%
        \fi
      \ifGread@
      \repeat
      \immediate\closein\@inputcheck
    \fi
    \ifGin@bbox
    \else
      \@latex@error
      {Cannot determine size of graphic in #1 (no BoundingBox)}%
      \@ehc
      \gdef\@gtempa{0 0 72 72 }%
    \fi
  \endgroup
  \expandafter\Gread@parse@bb\@gtempa\\%
}
\long\def\Gread@find@mbox#1 [#2]#3\\{% hash-ok
  \def\@tempa{#1}%
  \ifx\@tempa\Gread@MBox
    \gdef\@gtempa{#2 }%
    \@tempb
    \Gin@bboxtrue
  \fi
}
\def\Ginclude@png#1{%
  \hbox{%
% v0.02f add \@depth\z@ (from Sebastian)
    \pdfimage
      \@height\Gin@req@height \@width\Gin@req@width \@depth\z@
      \noexpand\noexpand\noexpand\@empty#1\relax
  }%
}

\def\Ginclude@mps#1{%
  \def\@tempa{!}%
  \ifx\Gin@scaley\@tempa
    \let\Gin@scaley\Gin@scalex
  \else
    \ifx\Gin@scalex\@tempa\let\Gin@scalex\Gin@scaley\fi
  \fi
  \hbox{%
    \GPT@ResetColorBegin
    \Gscale@box{\Gin@scalex}[\Gin@scaley]{%
      \@ifundefined{Gin@vllx}{%
        \GPT@viewportfalse
        % without viewport/trim clipping does not make sense
        % for pdfTeX
        \Gin@clipfalse
      }{}%
      \ifGin@clip
        \ifnum\driver@release<6 %
          \GPT@warn{No clipping support in pdfTeX < 0.14}%
        \else
          \if!\Gin@vllx\Gin@vlly\Gin@vurx\Gin@vury!%
          \else
            \let\GPT@clipend\GPT@DoClipEnd
            \setbox\@tempboxa\hbox\bgroup
          \fi
        \fi
      \fi
      \ifGPT@viewport
        \ifdim\Gin@vlly\p@=\z@
        \else
          \lower\Gin@vlly bp\hbox\bgroup
        \fi
        \ifdim\Gin@vllx\p@=\z@
        \else
          \hskip-\Gin@vllx bp\relax
        \fi
      \fi
      \convertMPtoPDF{#1}{1}{1}%
      \ifGPT@viewport
        \ifdim\Gin@vlly\p@=\z@
        \else
          \egroup
        \fi
        \GPT@clipend
      \fi
    }%
    \GPT@ResetColorEnd
  }%
}
\def\Gread@mps{%
  \GPT@read\Gread@eps
}
\ifnum\driver@release>3 %
  \let\Ginclude@png\Ginclude@pdftex
  \let\Ginclude@jpg\Ginclude@pdftex
  \let\Ginclude@pdf\Ginclude@pdftex
  \let\Gread@pdf\Gread@pdftex
  \let\Gread@png\Gread@pdfbitmap
  \let\Gread@jpg\Gread@pdfbitmap
  \ifnum\driver@release>5 %
    \ifnum\driver@release<9 %
      \let\Gread@tif\Gread@pdfbitmap
      \let\Ginclude@tif\Ginclude@pdftex
    \else
      \ifnum\driver@release>9 %
        \expandafter\let\csname Gread@jbig2\endcsname\Gread@pdfbitmap
        \expandafter\let\csname Ginclude@jbig2\endcsname\Ginclude@pdftex
      \fi
    \fi
  \fi
\else
  \def\Ginclude@pdf#1{%
    \def\@tempa{!}%
    \ifx\Gin@scaley\@tempa
      \let\Gin@scaley\Gin@scalex
    \else
      \ifx\Gin@scalex\@tempa\let\Gin@scalex\Gin@scaley\fi
    \fi
    \hbox{%
      \convertPDFtoPDF{#1}{\Gin@scalex}{\Gin@scaley} {0bp} {0bp}%
      {\Gin@req@width}{\Gin@req@height}%
    }%
  }%
\fi

% v0.02e: restrict the rules to just the types that pdftex can currently
% deal with.
\ifnum\driver@release>3 %
  \def\Gin@extensions{.png,.pdf,.jpg,.mps,.jpeg,.PNG,.PDF,.JPG,.JPEG}%
  \@namedef{Gin@rule@.jpg}#1{{jpg}{.jpg}{#1}}%
  \@namedef{Gin@rule@.jpeg}#1{{jpg}{.jpeg}{#1}}%
  \@namedef{Gin@rule@.JPG}#1{{jpg}{.JPG}{#1}}%
  \@namedef{Gin@rule@.JPEG}#1{{jpg}{.JPEG}{#1}}%
  \ifnum\driver@release>5 %
    \ifnum\driver@release<9 %
      \def\Gin@extensions{%
        .png,.pdf,.jpg,.mps,.tif,.jpeg,%
        .PNG,.PDF,.JPG,.JPEG%
      }%
      \@namedef{Gin@rule@.tif}#1{{tif}{.tif}{#1}}%
    \else
      \ifnum\driver@release>9 %
        \ifnum\pdfminorversion>3 %
          \def\Gin@extensions{%
            .png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,%
            .PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2%
          }%
        \fi
        \@namedef{Gin@rule@.jb2}#1{{jbig2}{.jb2}{#1}}%
        \@namedef{Gin@rule@.jbig2}#1{{jbig2}{.jbig2}{#1}}%
      \fi
    \fi
  \fi
\else
  \def\Gin@extensions{.png,.pdf,.mps,.PNG,.PDF}%
\fi
\@namedef{Gin@rule@.png}#1{{png}{.png}{#1}}
\@namedef{Gin@rule@.PNG}#1{{png}{.PNG}{#1}}
\@namedef{Gin@rule@.mps}#1{{mps}{.mps}{#1}}
\@namedef{Gin@rule@.pdf}#1{{pdf}{.pdf}{#1}}
\@namedef{Gin@rule@.PDF}#1{{pdf}{.PDF}{#1}}


% Rotation
% slightly hacky, but set width of box 0 to 0pt otherwise
% the CTM gets restored in the wrong place.

\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname pdfsetmatrix\endcsname\relax
  % Patrick Daly found an error here with doubled minus signs when
  % \Grot@sin is negative. Fixed.
  \def\Grot@start{%
    \pdfliteral{ %
      q %
      \Grot@cos\space\Grot@sin\space
      \if-\Grot@sin\else-\Grot@sin\fi\space\Grot@cos\space
      0 0 cm%
    }%
    \wd\z@\z@
  }%
  \def\Grot@end{%
    \pdfliteral{ Q}%
  }%
  % Scaling is OK, as graphics package does it right here.
  \def\Gscale@start{%
    \pdfliteral{ q %
      \Gscale@x\space0 0 \Gscale@y\space 0 0 cm%
    }%
  }%
\else
  \def\Grot@start{%
    \pdfsave
    \pdfsetmatrix{%
      \Grot@cos\space\Grot@sin\space
      \if-\Grot@sin\else-\Grot@sin\fi\space\Grot@cos
    }%
    \wd\z@\z@
  }%
  \def\Grot@end{\pdfrestore}%
  \def\Gscale@start{%
    \pdfsave
    \pdfsetmatrix{%
      \Gscale@x\space0 0 \Gscale@y
    }%
  }%
\fi
\let\Gscale@end\Grot@end

% undo the trig.sty `optimisation' so that these 0 1 and -1 values
% get written out as digits, not unexpandable TeX primitives.
\AtBeginDocument{%
  \expandafter\def\csname sin(0)\endcsname{0}%
  \expandafter\def\csname cos(0)\endcsname{1}%
  \expandafter\def\csname sin(90)\endcsname{1}%
  \expandafter\def\csname cos(90)\endcsname{0}%
  \expandafter\def\csname sin(-90)\endcsname{-1}%
  \expandafter\def\csname cos(-90)\endcsname{0}%
  \expandafter\def\csname sin(180)\endcsname{0}%
  \expandafter\def\csname cos(180)\endcsname{-1}%
}


% v0.02e: Restore catcodes of context letters.
% Not needed with current version of supp-pdf
% but protects against older versions.
% v0.03o: Catcode protection of '=' because of turkish.ldf.
\AtBeginDocument{%
  \GPT@catcodes{supp}%
  \InputIfFileExists{supp-pdf.mkii}{}{%
    \InputIfFileExists{supp-pdf}{}{}%
  }%
  % If supp-pdf is not available, \convertMPtoPDF generates
  % an error message. \providecommand inside the third argument
  % of \InputIfFileExists will not work:
  % * \InputIfFileExists has problems with parameters (#1).
  % * Implementation of \providecommand is insufficient in miniltx.tex
  \@ifundefined{convertMPtoPDF}{%
    \newcommand*{\convertMPtoPDF}[3]{%
      \GPT@error{%
        Cannot convert #1 from MPS to PDF.\MessageBreak
        The support file `supp-pdf.mkii' (supp-pdf.tex) is missing%
      }{%
        The graphics driver for pdfTeX needs `supp-pdf.mkii'\MessageBreak
        (or `supp-pdf.tex' and/or `supp-mis.tex')\MessageBreak
        to convert MetaPost output files to PDF.\MessageBreak
        These files are part of ConTeXt and can also be found here:%
        \MessageBreak
        \space\space CTAN:macros/pdftex/graphics/\MessageBreak
        You'll get more errors if you'll continue now.%
      }%
    }%
  }{}%
  \GPT@restore@supp
}

% Adds support for extended MetaPost features (transparency)
\def\LoadMetaPostSpecialExtensions{%
  \AtBeginDocument{%
    \GPT@catcodes{mpe}%
    \let\GPT@found=N%
    \IfFileExists{supp-pdf.mkii}{\let\GPT@found=Y}{%
      \IfFileExists{supp-pdf}{\let\GPT@found=Y}{}%
    }%
    \ifx Y\GPT@found
      \InputIfFileExists{supp-mis.mkii}{}{%
        \InputIfFileExists{supp-mis}{}{\let\GPT@found=N}%
      }%
      \ifx Y\GPT@found
        \InputIfFileExists{supp-mpe.mkii}{}{%
          \InputIfFileExists{supp-mpe}{}{\let\GPT@found=N}%
        }%
        \ifx Y\GPT@found
          \MPcmykcolorstrue
          \MPspotcolorstrue
          \chardef\makeMPintoPDFobject=1 %
        \else
          \GPT@warn{%
            Cannot enable MetaPost Special Extensions,\MessageBreak
            because `supp-mpe.mkii' (or `supp-mpe.tex')\MessageBreak
            is missing%
          }%
        \fi
      \else
        \GPT@warn{%
          Cannot enable MetaPost Special Extensions,\MessageBreak
          because `supp-mis.mkii' (or `supp-mis.tex')\MessageBreak
          is missing%
        }%
      \fi
    \else
      \GPT@warn{%
        Cannot enable support for MetaPost images,\MessageBreak
        because `supp-pdf.mkii' (or `supp-pdf.tex')\MessageBreak
        is missing%
      }%
    \fi
    \GPT@restore@mpe
  }%
  \let\LoadMetaPostSpecialExtensions\relax
}
\ifx\@onlypreamble\@undefined
\else
  \@onlypreamble\LoadMetaPostSpecialExtensions
\fi

% these seem to upset pdftex. ignore them. SPQR 1999/08/02
% allow for plain graphics, not graphicx.
% pdftex.def is loaded before the definition in graphicx,
% so do all the stuff \AtBeginDocument:
\AtBeginDocument{%
  \@ifundefined{define@key}{}{%
    \define@key{Gin}{natwidth}{}%
    \define@key{Gin}{natheight}{}%
  }%
}%
\GPT@endinput
