/*
 * BEGIN FLOCK GPL
 *
 * Copyright Flock Inc. 2005-2008
 * http://flock.com
 *
 * This file may be used under the terms of the
 * GNU General Public License Version 2 or later (the "GPL"),
 * http://www.gnu.org/licenses/gpl.html
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * END FLOCK GPL
 */

#include "nsISupports.idl"

#include "nsIURI.idl"
#include "nsIInputStream.idl"

#include "flockIError.idl"

[scriptable, uuid(f298760d-e6aa-4f4d-8923-bba602bdee99)]
interface flockIImageTransformOps : nsISupports
{
    /* URI from whence the image was loaded */
    readonly attribute nsIURI URI;

    /* format decoder used to load the image */
    readonly attribute string format;

    /* dimensions of the original image */
    readonly attribute PRInt32 width;
    readonly attribute PRInt32 height;

    /* set the dimensions for the resultant image (calls reset() implicitly) */
    void setDimensions(in PRUint32 width, in PRUint32 height);

    /* simple transformations */
    void translate(in double tx, in double ty);
    void scale(in double sx, in double sy);
    void rotate(in double angle);

    /* reset the current transformation matrix to the identity matrix */
    void reset();

    /* perform transformations and encode to stream */
    nsIInputStream saveToStream(in ACString format, in AString options);
};

[scriptable, uuid(432607db-5fc2-4cfd-ba37-76819f951465)]
interface flockIImageTransformListener : nsISupports
{
    /* called when the image is loaded and ready for use */
    void onImageTransformOpsReady(in flockIImageTransformOps ops);

    /* called if there was an error when loading */
    void onError(in flockIError error);
};

[scriptable, uuid(25f9e9b6-1994-4328-b906-85937158b0c2)]
interface flockIImageTransformService : nsISupports
{
    /* load an image for processing */
    void loadImage(in nsIURI uri, in flockIImageTransformListener listener);
};

%{C++

#define FLOCK_IMAGETRANSFORMSERVICE_CID            \
{ /* 7bfbd247-bc17-4955-9055-3b34a7e0e8b3 */       \
  0x7bfbd247,                                      \
  0xbc17,                                          \
  0x4955,                                          \
  {0x90, 0x55, 0x3b, 0x34, 0xa7, 0xe0, 0xe8, 0xb3} \
}

#define FLOCK_IMAGETRANSFORMSERVICE_CONTRACTID "@flock.com/image-transform-service;1"
#define FLOCK_IMAGETRANSFORMSERVICE_CLASSNAME "Flock Image Transform Service"

%}
