App Engine Java SDK version 1.9.8
[gae.git] / java / src / main / com / google / appengine / api / images / ImagesServiceFactoryImpl.java
blob26c1e439639bc91433c88ac0d0c344ce4db86bd8
1 // Copyright 2012 Google Inc. All rights reserved.
3 package com.google.appengine.api.images;
5 import com.google.appengine.api.blobstore.BlobKey;
6 import com.google.appengine.api.blobstore.BlobstoreServiceFactory;
8 import java.util.Collection;
10 /**
11 * Factory for creating an {@link ImagesService}, {@link Image}s and
12 * {@link Transform}s.
15 final class ImagesServiceFactoryImpl implements IImagesServiceFactory {
17 @Override
18 public ImagesService getImagesService() {
19 return new ImagesServiceImpl();
22 @Override
23 public Image makeImage(byte[] imageData) {
24 return new ImageImpl(imageData);
27 @Override
28 public Image makeImageFromBlob(BlobKey blobKey) {
29 return new ImageImpl(blobKey);
32 @Override
33 public Image makeImageFromFilename(String filename) {
34 BlobKey blobKey = BlobstoreServiceFactory.getBlobstoreService().createGsBlobKey(filename);
35 return new ImageImpl(blobKey);
38 @Override
39 public Transform makeResize(int width, int height) {
40 return new Resize(width, height, false, 0.0f, 0.0f);
43 @Override
44 public Transform makeResize(int width, int height, boolean allowStretch) {
45 return new Resize(width, height, allowStretch);
48 @Override
49 public Transform makeResize(int width, int height, float cropOffsetX, float cropOffsetY) {
50 return new Resize(width, height, true, cropOffsetX, cropOffsetY);
53 @Override
54 public Transform makeResize(int width, int height, double cropOffsetX,
55 double cropOffsetY) {
56 return new Resize(width, height, true, (float) cropOffsetX, (float) cropOffsetY);
59 @Override
60 public Transform makeCrop(float leftX, float topY, float rightX,
61 float bottomY) {
62 return new Crop(leftX, topY, rightX, bottomY);
65 @Override
66 public Transform makeCrop(double leftX, double topY,
67 double rightX, double bottomY) {
68 return makeCrop((float) leftX, (float) topY, (float) rightX, (float) bottomY);
71 @Override
72 public Transform makeVerticalFlip() {
73 return new VerticalFlip();
76 @Override
77 public Transform makeHorizontalFlip() {
78 return new HorizontalFlip();
81 @Override
82 public Transform makeRotate(int degrees) {
83 return new Rotate(degrees);
86 @Override
87 public Transform makeImFeelingLucky() {
88 return new ImFeelingLucky();
91 @Override
92 public CompositeTransform makeCompositeTransform(
93 Collection<Transform> transforms) {
94 return new CompositeTransform(transforms);
97 @Override
98 public CompositeTransform makeCompositeTransform() {
99 return new CompositeTransform();
102 @Override
103 public Composite makeComposite(Image image, int xOffset, int yOffset,
104 float opacity,
105 Composite.Anchor anchor) {
106 return new CompositeImpl(image, xOffset, yOffset, opacity, anchor);