TransitionAlpha.java revision fdacc8be92cd36f712cfdb0fcf9b0e847f8eeb58
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.media.videoeditor;
18
19
20/**
21 * This class allows to render an "alpha blending" transition according to a
22 * bitmap mask. The mask shows the shape of the transition all along the
23 * duration of the transition: just before the transition, video 1 is fully
24 * displayed. When the transition starts, as the time goes on, pixels of video 2
25 * replace pixels of video 1 according to the gray scale pixel value of the
26 * mask.
27 * {@hide}
28 */
29public class TransitionAlpha extends Transition {
30    /** This is the input JPEG file for the mask */
31    private final String mMaskFilename;
32
33    /**
34     * This is percentage (between 0 and 100) of blending between video 1 and
35     * video 2 if this value equals 0, then the mask is strictly applied if this
36     * value equals 100, then the mask is not at all applied (no transition
37     * effect)
38     */
39    private final int mBlendingPercent;
40
41    /**
42     * If true, this value inverts the direction of the mask: white pixels of
43     * the mask show video 2 pixels first black pixels of the mask show video 2
44     * pixels last.
45     */
46    private final boolean mIsInvert;
47
48    /**
49     * An object of this type cannot be instantiated by using the default
50     * constructor
51     */
52    @SuppressWarnings("unused")
53    private TransitionAlpha() {
54        this(null, null, null, 0, 0, null, 0, false);
55    }
56
57    /**
58     * Constructor
59     *
60     * @param transitionId The transition id
61     * @param afterMediaItem The transition is applied to the end of this
62     *      media item
63     * @param beforeMediaItem The transition is applied to the beginning of
64     *      this media item
65     * @param durationMs duration of the transition in milliseconds
66     * @param behavior behavior is one of the behavior defined in Transition
67     *            class
68     * @param maskFilename JPEG file name
69     * @param blendingPercent The blending percent applied
70     * @param invert true to invert the direction of the alpha blending
71     *
72     * @throws IllegalArgumentException if behavior is not supported, or if
73     *             direction are not supported.
74     */
75    public TransitionAlpha(String transitionId, MediaItem afterMediaItem,
76            MediaItem beforeMediaItem, long durationMs, int behavior, String maskFilename,
77            int blendingPercent, boolean invert) {
78        super(transitionId, afterMediaItem, beforeMediaItem, durationMs, behavior);
79
80        mMaskFilename = maskFilename;
81        mBlendingPercent = blendingPercent;
82        mIsInvert = invert;
83    }
84
85    /**
86     * @return The blending percentage
87     */
88    public int getBlendingPercent() {
89        return mBlendingPercent;
90    }
91
92    /**
93     * @return The mask filename
94     */
95    public String getMaskFilename() {
96        return mMaskFilename;
97    }
98
99    /**
100     * @return true if the direction of the alpha blending is inverted
101     */
102    public boolean isInvert() {
103        return mIsInvert;
104    }
105
106    /*
107     * {@inheritDoc}
108     */
109    @Override
110    public void generate() {
111    }
112}
113