* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkDistanceFieldGen_DEFINED
#define SkDistanceFieldGen_DEFINED
#include "include/core/SkTypes.h"
#define SK_DistanceFieldMagnitude 4
#define SK_DistanceFieldPad 4
#define SK_DistanceFieldInset 2
#define SK_DistanceFieldMultiplier "7.96875"
#define SK_DistanceFieldThreshold "0.50196078431"
* @param distanceField The distance field to be generated. Should already be allocated
* by the client with the padding above.
* @param image 8-bit mask we're using to generate the distance field.
* @param w Width of the original image.
* @param h Height of the original image.
* @param rowBytes Size of each row in the image, in bytes
*/
bool SkGenerateDistanceFieldFromA8Image(unsigned char* distanceField,
const unsigned char* image,
int w, int h, size_t rowBytes);
* @param distanceField The distance field to be generated. Should already be allocated
* by the client with the padding above.
* @param image 16-bit LCD data we're using to generate the distance field.
* @param w Width of the original image.
* @param h Height of the original image.
* @param rowBytes Size of each row in the image, in bytes
*/
bool SkGenerateDistanceFieldFromLCD16Mask(unsigned char* distanceField,
const unsigned char* image,
int w, int h, size_t rowBytes);
* @param distanceField The distance field to be generated. Should already be allocated
* by the client with the padding above.
* @param image 1-bit mask we're using to generate the distance field.
* @param w Width of the original image.
* @param h Height of the original image.
* @param rowBytes Size of each row in the image, in bytes
*/
bool SkGenerateDistanceFieldFromBWImage(unsigned char* distanceField,
const unsigned char* image,
int w, int h, size_t rowBytes);
* @param w Width of the original image.
* @param h Height of the original image.
*/
inline size_t SkComputeDistanceFieldSize(int w, int h) {
return (w + 2*SK_DistanceFieldPad) * (h + 2*SK_DistanceFieldPad) * sizeof(unsigned char);
}
#endif