本文整理汇总了C++中SkMatrix::asAffine方法的典型用法代码示例。如果您正苦于以下问题:C++ SkMatrix::asAffine方法的具体用法?C++ SkMatrix::asAffine怎么用?C++ SkMatrix::asAffine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkMatrix
的用法示例。
在下文中一共展示了SkMatrix::asAffine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AppendTransform
// static
void SkPDFUtils::AppendTransform(const SkMatrix& matrix, SkWStream* content) {
SkScalar values[6];
if (!matrix.asAffine(values)) {
SkMatrix::SetAffineIdentity(values);
}
for (size_t i = 0; i < SK_ARRAY_COUNT(values); i++) {
SkPDFScalar::Append(values[i], content);
content->writeText(" ");
}
content->writeText("cm\n");
}
示例2: nativeSetTransformAndClip
static void nativeSetTransformAndClip(JNIEnv* env, jclass thiz, jlong documentPtr, jint pageIndex,
jlong transformPtr, jint clipLeft, jint clipTop, jint clipRight, jint clipBottom) {
FPDF_DOCUMENT document = reinterpret_cast<FPDF_DOCUMENT>(documentPtr);
CPDF_Page* page = (CPDF_Page*) FPDF_LoadPage(document, pageIndex);
if (!page) {
jniThrowException(env, "java/lang/IllegalStateException",
"cannot open page");
return;
}
double width = 0;
double height = 0;
const int result = FPDF_GetPageSizeByIndex(document, pageIndex, &width, &height);
if (!result) {
jniThrowException(env, "java/lang/IllegalStateException",
"cannot get page size");
return;
}
CFX_AffineMatrix matrix;
SkMatrix* skTransform = reinterpret_cast<SkMatrix*>(transformPtr);
SkScalar transformValues[6];
if (!skTransform->asAffine(transformValues)) {
jniThrowException(env, "java/lang/IllegalArgumentException",
"transform matrix has perspective. Only affine matrices are allowed.");
return;
}
// PDF's coordinate system origin is left-bottom while in graphics it
// is the top-left. So, translate the PDF coordinates to ours.
matrix.Set(1, 0, 0, -1, 0, page->GetPageHeight());
// Apply the transformation what was created in our coordinates.
matrix.Concat(transformValues[SkMatrix::kAScaleX], transformValues[SkMatrix::kASkewY],
transformValues[SkMatrix::kASkewX], transformValues[SkMatrix::kAScaleY],
transformValues[SkMatrix::kATransX], transformValues[SkMatrix::kATransY]);
// Translate the result back to PDF coordinates.
matrix.Concat(1, 0, 0, -1, 0, page->GetPageHeight());
FS_MATRIX transform = {matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f};
FS_RECTF clip = {(float) clipLeft, (float) clipTop, (float) clipRight, (float) clipBottom};
FPDFPage_TransFormWithClip(page, &transform, &clip);
FPDF_ClosePage(page);
}
示例3: NativeIsAffine
Boolean Matrix::NativeIsAffine(
/* [in] */ Int64 objHandle)
{
SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
return obj->asAffine(NULL) ? TRUE : FALSE;
}
示例4: isAffine
static jboolean isAffine(JNIEnv* env, jobject clazz, jlong objHandle) {
SkMatrix* obj = reinterpret_cast<SkMatrix*>(objHandle);
return obj->asAffine(NULL) ? JNI_TRUE : JNI_FALSE;
}