当前位置: 首页>>代码示例>>Java>>正文


Java Transform类代码示例

本文整理汇总了Java中com.google.appengine.api.images.Transform的典型用法代码示例。如果您正苦于以下问题:Java Transform类的具体用法?Java Transform怎么用?Java Transform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Transform类属于com.google.appengine.api.images包,在下文中一共展示了Transform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convert

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
public byte[] convert(byte[] image, String destType, boolean reverse) {
	if (destType == null) {
		throw new IllegalArgumentException("dest type is null.");
	} else {
		destType = destType.toLowerCase();
	}

	ImagesService.OutputEncoding encoding = null;
	if ("png".equals(destType)) {
		encoding = OutputEncoding.PNG;
	} else if ("jpeg".equals(destType)) {
		encoding = OutputEncoding.JPEG;
	} else {
		throw new UnsupportedOperationException("unsupported image encoding: " + destType);
	}

	ImagesService imagesService = ImagesServiceFactory.getImagesService();
	Image bmp = ImagesServiceFactory.makeImage(image);

	Transform t = (reverse) ? ImagesServiceFactory.makeVerticalFlip() : ImagesServiceFactory.makeCompositeTransform();
	return imagesService.applyTransform(t, bmp, encoding).getImageData();
}
 
开发者ID:hidekatsu-izuno,项目名称:wmf2svg,代码行数:23,代码来源:ImageUtil.java

示例2: testResizeWithCrop

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
@Test
public void testResizeWithCrop() throws IOException {
    int resizedWidth = 300;
    int resizedHeight = 200;
    Image originalImage = readImage(CAPEDWARF_PNG);
    Transform resize = ImagesServiceFactory.makeResize(resizedWidth, resizedHeight, 0.5f, 0.5f);
    Image resizedImage = imagesService.applyTransform(resize, originalImage);
    assertEquals(resizedWidth, resizedImage.getWidth());
    assertEquals(resizedHeight, resizedImage.getHeight());

    originalImage = readImage(CAPEDWARF_PNG);
    resize = ImagesServiceFactory.makeResize(resizedWidth, resizedHeight, 0.5, 0.5);
    resizedImage = imagesService.applyTransform(resize, originalImage);
    assertEquals(resizedWidth, resizedImage.getWidth());
    assertEquals(resizedHeight, resizedImage.getHeight());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:17,代码来源:TransformationsTest.java

示例3: testRotate

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
@Test
public void testRotate() throws IOException {
    ChkType chkType;
    for (int dg : DEGREES) {
        Transform transform = ImagesServiceFactory.makeRotate(dg);
        if ((dg == 90) || (dg == 270)) {
            chkType = ChkType.ROTATE;
        } else {
            chkType = ChkType.FLIP;
        }
        for (String sfile : FNAMES) {
            for (OutputEncoding encoding : ENCODES) {
                applyAndVerify(sfile, transform, chkType, encoding);
            }
        }
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:18,代码来源:ImagesServiceTest.java

示例4: applyAndVerify

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
private void applyAndVerify(String fname, Transform transform, ChkType chkType, OutputEncoding outType) throws IOException {
    int expectedWidth = -1;
    int expectedHeight = -1;

    Image image = readImage(fname);
    if (chkType == ChkType.FLIP) {
        expectedWidth = image.getWidth();
        expectedHeight = image.getHeight();
    } else if (chkType == ChkType.ROTATE) {
        expectedWidth = image.getHeight();
        expectedHeight = image.getWidth();
    } else if (chkType == ChkType.CROP) {
        expectedWidth = image.getWidth() / 2;
        expectedHeight = image.getHeight() / 2;
    }
    Image transImg = imagesService.applyTransform(transform, image, outType);
    assertEquals(expectedWidth, transImg.getWidth());
    assertEquals(expectedHeight, transImg.getHeight());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:20,代码来源:ImagesServiceTest.java

示例5: getResizedImageBytes

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
public byte[] getResizedImageBytes(BlobKey id, int width, int height) {
  log.info("Resizing " + id + " to " + width + "x" + height);
  // emptyImage is just a wrapper around the id.
  Image emptyImage = ImagesServiceFactory.makeImageFromBlob(id);
  Transform resize = ImagesServiceFactory.makeResize(width, height);
  return imagesService.applyTransform(resize, emptyImage).getImageData();
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:8,代码来源:RawAttachmentService.java

示例6: resizeImage

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
@Override
public byte[] resizeImage(byte[] imageBlob, int width, int height) {
  ImagesService imagesService = ImagesServiceFactory.getImagesService();
  Transform resize = ImagesServiceFactory.makeResize(width, height);

  Image oldImage = ImagesServiceFactory.makeImage(imageBlob);
  Image newImage = imagesService.applyTransform(resize, oldImage);

  imageBlob = newImage.getImageData();
  return imageBlob;
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:12,代码来源:ImageUtilImpl.java

示例7: read

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
public BufferedImage read(byte[] imageBytes) throws IOException {
	Image image = ImagesServiceFactory.makeImage(imageBytes);
	Transform identity = ImagesServiceFactory.makeRotate(0);
	OutputEncoding intermediateFormat = OutputEncoding.PNG;
	Image intermediateImage = imagesService.applyTransform(identity, image, intermediateFormat);
	byte[] intermediateBytes = intermediateImage.getImageData();
	return SANSELAN.getIO(imagesService).read(intermediateBytes);
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:9,代码来源:ServiceImageIO.java

示例8: getCropTransform

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
private Transform getCropTransform() {
    Double height = Double.parseDouble(heightString);
    Double width = Double.parseDouble(widthString);
    Double leftX = Double.parseDouble(leftXString) / width;
    Double topY = Double.parseDouble(topYString) / height;
    Double rightX = Double.parseDouble(rightXString) / width;
    Double bottomY = Double.parseDouble(bottomYString) / height;
    return ImagesServiceFactory.makeCrop(leftX, topY, rightX, bottomY);
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:10,代码来源:StudentProfilePictureEditAction.java

示例9: getCompositeTransformToApply

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
private CompositeTransform getCompositeTransformToApply() {
    Transform standardCompress = ImagesServiceFactory.makeResize(150, 150);
    return ImagesServiceFactory.makeCompositeTransform()
            .concatenate(getScaleTransform())
            .concatenate(getRotateTransform())
            .concatenate(getCropTransform())
            .concatenate(standardCompress);
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:9,代码来源:StudentProfilePictureEditAction.java

示例10: getFieldValue

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected <V> V getFieldValue(Transform op, Field field) {
    try {
        return (V) field.get(op);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:9,代码来源:CapeDwarfImageLifecycle.java

示例11: testHorizontalFlip

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
@Test
public void testHorizontalFlip() throws IOException {
    Image image = readImage("capedwarf.png");
    Transform horizontalFlip = ImagesServiceFactory.makeHorizontalFlip();

    Image flippedImage = imagesService.applyTransform(horizontalFlip, image);

    assertNotNull(flippedImage);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:10,代码来源:IntegrationTest.java

示例12: testResize

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
@Test
public void testResize() throws IOException {
    assumeEnvironment(Environment.APPSPOT, Environment.CAPEDWARF);
    int resizeWidth = 150;
    int resizeHeigh = 150;
    Transform transform = ImagesServiceFactory.makeResize(resizeWidth, resizeHeigh);
    assertTransformation(transform, "Resize");
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:9,代码来源:TifImageTest.java

示例13: testRotate

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
@Test
public void testRotate() throws IOException {
    assumeEnvironment(Environment.APPSPOT, Environment.CAPEDWARF);
    int rotageDegree = 90;
    Transform transform = ImagesServiceFactory.makeRotate(rotageDegree);
    assertTransformation(transform, "Rotate");
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:8,代码来源:TifImageTest.java

示例14: testCrop

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
@Test
public void testCrop() throws IOException {
    assumeEnvironment(Environment.APPSPOT, Environment.CAPEDWARF);
    double cropLeftX = 0.0;
    double cropTopY = 0.0;
    double cropRightX = 0.5;
    double cropBottomY = 0.5;
    Transform transform = ImagesServiceFactory.makeCrop(
        cropLeftX,
        cropTopY,
        cropRightX,
        cropBottomY
    );
    assertTransformation(transform, "Crop");
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:16,代码来源:TifImageTest.java

示例15: assertTransformation

import com.google.appengine.api.images.Transform; //导入依赖的package包/类
private void assertTransformation(Transform transform, String transformType) throws IOException {
    String expectedImage = "beach" + transformType + ".";
    for (OutputEncoding outType : OUTPUT_ENCODE) {
        String expectImageFile = expectedImage + outType.toString().toLowerCase();
        Image expected = readImage(expectImageFile);
        Image image = readImage(BEACH_TIF);
        Image transImg = imagesService.applyTransform(transform, image, outType);

        assertImages(transform, expected, transImg);
    }
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:12,代码来源:TifImageTest.java


注:本文中的com.google.appengine.api.images.Transform类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。