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
;
11 * Factory for creating an {@link ImagesService}, {@link Image}s and
15 final class ImagesServiceFactoryImpl
implements IImagesServiceFactory
{
18 public ImagesService
getImagesService() {
19 return new ImagesServiceImpl();
23 public Image
makeImage(byte[] imageData
) {
24 return new ImageImpl(imageData
);
28 public Image
makeImageFromBlob(BlobKey blobKey
) {
29 return new ImageImpl(blobKey
);
33 public Image
makeImageFromFilename(String filename
) {
34 BlobKey blobKey
= BlobstoreServiceFactory
.getBlobstoreService().createGsBlobKey(filename
);
35 return new ImageImpl(blobKey
);
39 public Transform
makeResize(int width
, int height
) {
40 return new Resize(width
, height
, false, 0.0f
, 0.0f
);
44 public Transform
makeResize(int width
, int height
, boolean allowStretch
) {
45 return new Resize(width
, height
, allowStretch
);
49 public Transform
makeResize(int width
, int height
, float cropOffsetX
, float cropOffsetY
) {
50 return new Resize(width
, height
, true, cropOffsetX
, cropOffsetY
);
54 public Transform
makeResize(int width
, int height
, double cropOffsetX
,
56 return new Resize(width
, height
, true, (float) cropOffsetX
, (float) cropOffsetY
);
60 public Transform
makeCrop(float leftX
, float topY
, float rightX
,
62 return new Crop(leftX
, topY
, rightX
, bottomY
);
66 public Transform
makeCrop(double leftX
, double topY
,
67 double rightX
, double bottomY
) {
68 return makeCrop((float) leftX
, (float) topY
, (float) rightX
, (float) bottomY
);
72 public Transform
makeVerticalFlip() {
73 return new VerticalFlip();
77 public Transform
makeHorizontalFlip() {
78 return new HorizontalFlip();
82 public Transform
makeRotate(int degrees
) {
83 return new Rotate(degrees
);
87 public Transform
makeImFeelingLucky() {
88 return new ImFeelingLucky();
92 public CompositeTransform
makeCompositeTransform(
93 Collection
<Transform
> transforms
) {
94 return new CompositeTransform(transforms
);
98 public CompositeTransform
makeCompositeTransform() {
99 return new CompositeTransform();
103 public Composite
makeComposite(Image image
, int xOffset
, int yOffset
,
105 Composite
.Anchor anchor
) {
106 return new CompositeImpl(image
, xOffset
, yOffset
, opacity
, anchor
);