TransitionAlpha.java revision 21e9da6f446301756ddabbfb9d61155db5480366
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 media 62 * item 63 * @param beforeMediaItem The transition is applied to the beginning of this 64 * 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. The dimension of the image 69 * corresponds to 720p (16:9 aspect ratio). Mask files are 70 * shared between video editors and can be created in the 71 * projects folder (the parent folder for all projects). 72 * @param blendingPercent The blending percent applied 73 * @param invert true to invert the direction of the alpha blending 74 * @throws IllegalArgumentException if behavior is not supported, or if 75 * direction are not supported. 76 */ 77 public TransitionAlpha(String transitionId, MediaItem afterMediaItem, 78 MediaItem beforeMediaItem, long durationMs, int behavior, String maskFilename, 79 int blendingPercent, boolean invert) { 80 super(transitionId, afterMediaItem, beforeMediaItem, durationMs, behavior); 81 82 mMaskFilename = maskFilename; 83 mBlendingPercent = blendingPercent; 84 mIsInvert = invert; 85 } 86 87 /** 88 * @return The blending percentage 89 */ 90 public int getBlendingPercent() { 91 return mBlendingPercent; 92 } 93 94 /** 95 * @return The mask filename 96 */ 97 public String getMaskFilename() { 98 return mMaskFilename; 99 } 100 101 /** 102 * @return true if the direction of the alpha blending is inverted 103 */ 104 public boolean isInvert() { 105 return mIsInvert; 106 } 107 108 /* 109 * {@inheritDoc} 110 */ 111 @Override 112 public void generate() { 113 } 114} 115