2011-07-28 14:26:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2008-12-18 19:26:11 +00:00
|
|
|
#ifndef SkCGUtils_DEFINED
|
|
|
|
#define SkCGUtils_DEFINED
|
|
|
|
|
2010-12-20 18:26:13 +00:00
|
|
|
#include "SkTypes.h"
|
|
|
|
|
|
|
|
#ifdef SK_BUILD_FOR_MAC
|
2011-06-21 13:09:32 +00:00
|
|
|
#include <ApplicationServices/ApplicationServices.h>
|
2010-12-20 18:26:13 +00:00
|
|
|
#endif
|
2008-12-18 19:26:11 +00:00
|
|
|
|
2011-06-23 22:27:30 +00:00
|
|
|
#ifdef SK_BUILD_FOR_IOS
|
|
|
|
#include <CoreGraphics/CoreGraphics.h>
|
|
|
|
#endif
|
|
|
|
|
2008-12-18 19:26:11 +00:00
|
|
|
class SkBitmap;
|
2011-06-28 20:54:03 +00:00
|
|
|
class SkStream;
|
2008-12-18 19:26:11 +00:00
|
|
|
|
2011-01-03 13:48:50 +00:00
|
|
|
/**
|
|
|
|
* Create an imageref from the specified bitmap using the specified colorspace.
|
2011-01-05 16:29:02 +00:00
|
|
|
* If space is NULL, then CGColorSpaceCreateDeviceRGB() is used.
|
2011-01-03 13:48:50 +00:00
|
|
|
*/
|
2012-02-09 22:09:41 +00:00
|
|
|
SK_API CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm,
|
|
|
|
CGColorSpaceRef space);
|
2008-12-18 19:26:11 +00:00
|
|
|
|
2011-01-03 13:48:50 +00:00
|
|
|
/**
|
2011-01-05 16:29:02 +00:00
|
|
|
* Create an imageref from the specified bitmap using the colorspace returned
|
|
|
|
* by CGColorSpaceCreateDeviceRGB()
|
2011-01-03 13:48:50 +00:00
|
|
|
*/
|
2011-01-04 01:29:52 +00:00
|
|
|
static inline CGImageRef SkCreateCGImageRef(const SkBitmap& bm) {
|
2011-01-03 13:48:50 +00:00
|
|
|
return SkCreateCGImageRefWithColorspace(bm, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw the bitmap into the specified CG context. The bitmap will be converted
|
|
|
|
* to a CGImage using the generic RGB colorspace. (x,y) specifies the position
|
2011-01-05 16:29:02 +00:00
|
|
|
* of the top-left corner of the bitmap. The bitmap is converted using the
|
|
|
|
* colorspace returned by CGColorSpaceCreateDeviceRGB()
|
2011-01-03 13:48:50 +00:00
|
|
|
*/
|
2010-12-20 18:26:13 +00:00
|
|
|
void SkCGDrawBitmap(CGContextRef, const SkBitmap&, float x, float y);
|
|
|
|
|
2011-06-28 20:54:03 +00:00
|
|
|
bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output);
|
|
|
|
|
2012-02-24 15:29:00 +00:00
|
|
|
/**
|
|
|
|
* Return a provider that wraps the specified stream. It will become an
|
|
|
|
* owner of the stream, so the caller must still manage its ownership.
|
|
|
|
*
|
|
|
|
* To hand-off ownership of the stream to the provider, the caller must do
|
|
|
|
* something like the following:
|
|
|
|
*
|
|
|
|
* SkStream* stream = new ...;
|
|
|
|
* CGDataProviderRef provider = SkStreamToDataProvider(stream);
|
|
|
|
* stream->unref();
|
|
|
|
*
|
|
|
|
* Now when the provider is finally deleted, it will delete the stream.
|
|
|
|
*/
|
|
|
|
CGDataProviderRef SkCreateDataProviderFromStream(SkStream*);
|
|
|
|
|
2008-12-18 19:26:11 +00:00
|
|
|
#endif
|