javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/AnimationPlayer.java
changeset 23 98ccebc37403
child 26 dc7c549001d5
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 /**
       
    18  * 
       
    19  */
       
    20 package com.nokia.microedition.media.animation;
       
    21 
       
    22 import java.io.InputStream;
       
    23 import java.util.Enumeration;
       
    24 import java.util.Hashtable;
       
    25 
       
    26 import javax.microedition.media.Control;
       
    27 import javax.microedition.media.MediaException;
       
    28 import javax.microedition.media.PlayerListener;
       
    29 import javax.microedition.media.protocol.DataSource;
       
    30 
       
    31 import org.eclipse.ercp.swt.mobile.MobileShell;
       
    32 import org.eclipse.swt.SWTException;
       
    33 import org.eclipse.swt.events.PaintEvent;
       
    34 import org.eclipse.swt.events.PaintListener;
       
    35 import org.eclipse.swt.graphics.GC;
       
    36 import org.eclipse.swt.graphics.Image;
       
    37 import org.eclipse.swt.graphics.ImageData;
       
    38 import org.eclipse.swt.graphics.ImageLoader;
       
    39 import org.eclipse.swt.graphics.Point;
       
    40 import org.eclipse.swt.widgets.Display;
       
    41 import org.eclipse.swt.widgets.Shell;
       
    42 
       
    43 import com.nokia.microedition.media.BufferDataSource;
       
    44 import com.nokia.microedition.media.InputStreamDataSource;
       
    45 import com.nokia.microedition.media.InputStreamSourceStream;
       
    46 import com.nokia.microedition.media.Locator;
       
    47 import com.nokia.microedition.media.PlayerBase;
       
    48 import com.nokia.microedition.media.PlayerListenerImpl;
       
    49 
       
    50 /**
       
    51  * @author d35kumar
       
    52  *
       
    53  */
       
    54 public class AnimationPlayer extends PlayerBase {
       
    55 	// GIF image information, array length will be equal to the number of frames in image 
       
    56 	protected ImageData [] iImageData;
       
    57 	// number of times we need to repeat the animation
       
    58 	// by default it's value is one 
       
    59 	private int iTotalLoopCount=1;
       
    60 	// this holds all control related to this player 
       
    61 	Hashtable iControls= new Hashtable();
       
    62 	// Current frame index of the Animation file
       
    63 	private int iFrameindex;
       
    64 	// Current Loop Count 
       
    65 	private int iCurrentLoopCount;
       
    66 	// Display object of the eSWT API, creating this object will integrate the current java code with eSWT API. 
       
    67 	Display iDisplay; 
       
    68 	// Control object of ESWT API, return from LCDUIInvoker. 
       
    69 	org.eclipse.swt.widgets.Control iControl;
       
    70 	// Constants used everywhere to compare the string 
       
    71 	private static final String ANIMATION_CONTENT_TYPE = "image/gif";
       
    72 	
       
    73 	private final String fVideoControl=VideoControl.class.getName();
       
    74 	private final String fFramePositioningControl=FramePositioningControl.class.getName();
       
    75 	private final String fStopTimeControl=StopTimeControl.class.getName();
       
    76 	private final String fRateControl=RateControl.class.getName();
       
    77 	 /**
       
    78      * Default control package. Used when getting control with
       
    79      * getControl method which appends default control package if package is
       
    80      * not specified.
       
    81      */
       
    82     static final String CONTROL_DEFAULT_PACKAGE =
       
    83         "javax.microedition.media.control.";
       
    84     
       
    85 	//For Player listener 
       
    86 	protected PlayerListenerImpl iPlayerListenerImpl;
       
    87 	//Image to be displayed, again object of eSWT API. 
       
    88 	protected Image iImage;
       
    89 	// Actual dimension of the image, this should be initialized while creating the player
       
    90 	// as user can change the size of the image later, in that case too, getSourceheight and getSourceWidth 
       
    91 	// of VideoControl should return the actual width and height of the image 
       
    92 	Point iSourceDimension;
       
    93 	long iMediaTime;
       
    94 	
       
    95 	// Display Location, of the image   
       
    96 	private Point iDisplayLocation= new Point(0,0);
       
    97 	
       
    98 
       
    99 	/**
       
   100 	 * 
       
   101 	 * @param ds DataSource which contains the data to be displayed 
       
   102 	 */
       
   103 	public AnimationPlayer(DataSource ds){
       
   104 		final String DEBUG_STR="AnimationPlayer::AnimationPlayer(DataSource)";
       
   105 		System.out.println(DEBUG_STR+"+");
       
   106 		iPlayerListenerImpl= new PlayerListenerImpl(this);
       
   107 		//TODO check if we can do it in better way 
       
   108 		// this is temporary solution
       
   109 		// for this I have written two functions getDataSource and getInputStream function 
       
   110 		BufferDataSource bds =(BufferDataSource )ds;
       
   111 		InputStreamDataSource isds=(InputStreamDataSource)bds.getDataSource();
       
   112 		InputStreamSourceStream isss=(InputStreamSourceStream )isds.getStreams()[0];
       
   113 		InputStream is = isss.getInputStream();
       
   114 		
       
   115 		if(is!=null){
       
   116 			ImageLoader imageLoader= new ImageLoader();
       
   117 			iImageData=imageLoader.load(is);
       
   118 			//iRepeatCount=imageLoader.repeatCount;
       
   119 			iSourceDimension= new Point(imageLoader.logicalScreenWidth, imageLoader.logicalScreenHeight);
       
   120 		}
       
   121 		pupulateControl();
       
   122 		System.out.println(DEBUG_STR+"-");
       
   123 	}
       
   124 	
       
   125 	/**
       
   126 	 * 
       
   127 	 * @param locator
       
   128 	 * @throws SWTException
       
   129 	 */
       
   130 	public AnimationPlayer(String locator) throws SWTException{
       
   131 		final String DEBUG_STR="AnimationPlayer::AnimationPlayer(Locator )";
       
   132 		System.out.println(DEBUG_STR+"+");
       
   133 		ImageLoader imageLoader= new ImageLoader();
       
   134 		System.out.println(DEBUG_STR+"Locator string is "+locator);
       
   135 		// Following line may throw SWTException 
       
   136 		iImageData=imageLoader.load(locator);
       
   137 		//iRepeatCount=imageLoader.repeatCount;
       
   138 		iSourceDimension= new Point(imageLoader.logicalScreenWidth, imageLoader.logicalScreenHeight);
       
   139 		pupulateControl();
       
   140 		System.out.println(DEBUG_STR+"-");
       
   141 	}
       
   142 	
       
   143 	/**
       
   144 	 * Moved the player to close state and releases all resources, called from PlayerBase class  
       
   145 	 */
       
   146 	protected void doClose() {
       
   147 		final String DEBUG_STR="AnimationPlayer::doClose()";
       
   148 		System.out.println(DEBUG_STR+"+");
       
   149 		iState=CLOSED;
       
   150 		iPlayerListenerImpl.postEvent(PlayerListener.CLOSED, null);
       
   151 		System.out.println(DEBUG_STR+"-");
       
   152 	}
       
   153 
       
   154 	protected void doDeallocate() {
       
   155 		// what to do here, nullify image data and display etc???
       
   156 	}
       
   157 
       
   158 	protected void doPrefetch() throws MediaException {
       
   159 		final String DEBUG_STR="AnimationPlayer::doPrefetch()";
       
   160 		System.out.println(DEBUG_STR+"+");
       
   161 		iState=PREFETCHED;
       
   162 		System.out.println(DEBUG_STR+"-");
       
   163 	}
       
   164 
       
   165 	protected void doRealize() throws MediaException {
       
   166 		final String DEBUG_STR="AnimationPlayer::doRealize()";
       
   167 		System.out.println(DEBUG_STR+"+");
       
   168 		iState=REALIZED;
       
   169 		// this is temporary solution implement it in proper way 
       
   170 		iImage=new Image(iDisplay, iImageData[0]);
       
   171 		System.out.println(DEBUG_STR+"-");
       
   172 	}
       
   173 
       
   174 	protected void doStop() throws MediaException {
       
   175 		final String DEBUG_STR="AnimationPlayer::doStop()";
       
   176 		System.out.println(DEBUG_STR+"+");
       
   177 		// since after stopping the player the player state will move to pre-fetched state 
       
   178 		iState=PREFETCHED;
       
   179 		iPlayerListenerImpl.postEvent(PlayerListener.STOPPED, new Long(iMediaTime * 10000));
       
   180 		System.out.println(DEBUG_STR+"-");
       
   181 	}
       
   182 
       
   183 	public void addControl(Control aControl, String aControlType)
       
   184 			throws MediaException {
       
   185 		iControls.put(aControlType, aControl);
       
   186 	}
       
   187 
       
   188 	public void addPlayerListener(PlayerListener aPlayerListener) {
       
   189 		closeCheck();
       
   190         iPlayerListenerImpl.addPlayerListener(aPlayerListener);
       
   191 	}
       
   192 	
       
   193 	/**
       
   194 	 * Returns the Content type("image/GIF") supported for by this player, 
       
   195 	 */
       
   196 	public String getContentType() {
       
   197 		closeCheck();
       
   198         unrealizedCheck();
       
   199 		return ANIMATION_CONTENT_TYPE;
       
   200 	}
       
   201 	
       
   202 	/**
       
   203 	 * This function will return, total time in microseconds this player can be played 
       
   204 	 */
       
   205 	public long getDuration() {
       
   206 		closeCheck();
       
   207 		long time = TIME_UNKNOWN;
       
   208 		int totalNoOfFrames = iImageData.length;
       
   209 		for (int i = 0; i < totalNoOfFrames; i++) {
       
   210 			time += iImageData[i].delayTime;
       
   211 		}
       
   212 		// Since we have to return it in microsecond multiply it with 1000; 
       
   213 		return time * 10000;
       
   214 	}
       
   215 	
       
   216 	/**
       
   217 	 * This returned the total time taken, till now, to play the video.  
       
   218 	 */
       
   219 	public long getMediaTime() {
       
   220 		return iMediaTime*10000;
       
   221 	}
       
   222 
       
   223 	public int getState() {
       
   224 		return iState;
       
   225 	}
       
   226 	
       
   227 	/**
       
   228 	 * Removes the specified playerListner from this player  
       
   229 	 */
       
   230 	public void removePlayerListener(PlayerListener aPlayerListener) {
       
   231 		closeCheck();
       
   232         iPlayerListenerImpl.removePlayerListener(aPlayerListener);
       
   233 	}
       
   234 	public void start() throws MediaException {
       
   235 		final String DEBUG_STR = "AnimationPlayer::start()";
       
   236 //		prefetch();
       
   237 		initialize();
       
   238 		addPaintListener(iControl);
       
   239 		iState = STARTED;
       
   240 		Thread thread = new Thread("Animation") {
       
   241 			int frameIndex = iFrameindex;
       
   242 			int loopCount = iCurrentLoopCount;
       
   243 			GC gc=null;
       
   244 			public void run() {
       
   245 				final int noOfFrames = iImageData.length;
       
   246 				while (frameIndex < noOfFrames && (loopCount < iTotalLoopCount)
       
   247 						&& (iState == STARTED)) {
       
   248 					final int delayTimeForNextFrame = iImageData[frameIndex].delayTime;
       
   249 					System.out.println("\n\n\n************" + DEBUG_STR
       
   250 							+ "Inside the while loop " + frameIndex + "/"
       
   251 							+ noOfFrames);
       
   252 					// Since we are going to display first frame, notify all
       
   253 					// PlayerListener that Player has started
       
   254 					if (frameIndex == 0) {
       
   255 						iPlayerListenerImpl.postEvent(PlayerListener.STARTED,
       
   256 								new Long(iMediaTime * 10000));
       
   257 					}
       
   258 					iDisplay.asyncExec(new Runnable() {
       
   259 						public void run() {
       
   260 							System.out.println(DEBUG_STR+"Inside run method");
       
   261 							try {
       
   262 								if (gc == null)gc = new GC(iImage);
       
   263 							} catch (Exception e) {
       
   264 								// TODO Auto-generated catch block
       
   265 								e.printStackTrace();
       
   266 							}
       
   267 							System.out.println(DEBUG_STR+"Inside run method246");
       
   268 							Image tempImage = new Image(iDisplay,
       
   269 									iImageData[frameIndex]);
       
   270 							System.out.println(DEBUG_STR+"Inside run method246");
       
   271 							gc.drawImage(tempImage, 0, 0);
       
   272 							tempImage.dispose();
       
   273 							frameIndex = (frameIndex + 1) % noOfFrames;
       
   274 							System.out.println(DEBUG_STR+"Inside run method253>>>>>>>>>"+frameIndex);
       
   275 							iControl.redraw();
       
   276 							// update the mediaTime, as Animation progress
       
   277 							iMediaTime += delayTimeForNextFrame;
       
   278 							// If imageIndex becomes zero it means, all frames
       
   279 							// has been displayed
       
   280 							// So increase the loopCount
       
   281 							if (frameIndex == 0) {
       
   282 								// send the END_OF_MEDIA event to all listener
       
   283 								iPlayerListenerImpl.postEvent(
       
   284 										PlayerListener.END_OF_MEDIA, new Long(
       
   285 												iMediaTime * 10000));
       
   286 								loopCount++;
       
   287 								// since player is again going to start from the
       
   288 								// first frame
       
   289 								// so media time should be set to zero
       
   290 								iMediaTime = 0;
       
   291 							}
       
   292 							System.out
       
   293 									.println(DEBUG_STR
       
   294 											+ "end of asynchronous block imageIndex is "
       
   295 											+ frameIndex + " and loop count is"
       
   296 											+ loopCount );
       
   297 						}
       
   298 					});
       
   299 					try {
       
   300 						Thread.sleep(delayTimeForNextFrame * 10);
       
   301 					} catch (InterruptedException e) {
       
   302 						// TODO Auto-generated catch block
       
   303 						e.printStackTrace();
       
   304 					}
       
   305 					System.out
       
   306 							.println("**********************End of while loop\n\n\n");
       
   307 				}
       
   308 				iCurrentLoopCount=loopCount;
       
   309 				System.out.println(DEBUG_STR + "Came out side the while loop "
       
   310 						+ iState);
       
   311 			}
       
   312 		};
       
   313 		thread.start();
       
   314 		System.out.println(DEBUG_STR + "-");
       
   315 		// }catch(Exception e){
       
   316 		// System.out.println(DEBUG_STR+"Exception caught"+e);
       
   317 		// e.printStackTrace();
       
   318 		// }
       
   319 	}
       
   320 	
       
   321 	/**
       
   322 	 * This function is also being called from VideoControl class, 
       
   323 	 * Since on each event 
       
   324 	 * @param aControl
       
   325 	 * @throws MediaException 
       
   326 	 */
       
   327 	 void addPaintListener(org.eclipse.swt.widgets.Control aControl) throws MediaException{
       
   328 		 final String DEBUG_STR="AnimationPlayer::addPaintListener()";
       
   329 		 iControl=aControl;
       
   330 		// iDisplay and IControl shouldn't be null here 
       
   331 		System.out.println(DEBUG_STR+" Control is "+iControl+" Display "+iDisplay);
       
   332 		// Following line should never execute
       
   333 		// TODO check what message to provide in case of Exception 
       
   334 		if(iControl==null)
       
   335 			throw new MediaException("Update this message");
       
   336 		iDisplay.syncExec(new Runnable(){
       
   337 			public void run() {
       
   338 				// if user is writing his MIDlet using eSWT API, then the Control object will be MobileShell
       
   339 				// and in that case it is mandatory to open the shell
       
   340 //				if(iControl instanceof MobileShell){
       
   341 				if(iControl instanceof Shell){
       
   342 					((Shell)iControl).open();
       
   343 				}
       
   344 				iControl.addPaintListener(new PaintListener(){
       
   345 					public void paintControl(PaintEvent pe) {
       
   346 //						System.out.println(DEBUG_STR+"paintControl() paintEvent is "+pe);
       
   347 //						System.out.println(DEBUG_STR+"paintControl() Display location is "+iDisplayLocation.x+", "+iDisplayLocation.y);
       
   348 						if(iImage!=null){
       
   349 							pe.gc.drawImage(iImage, iDisplayLocation.x, iDisplayLocation.y);
       
   350 						}
       
   351 					}
       
   352 				});
       
   353 			}
       
   354 		});
       
   355 	}
       
   356 	/**
       
   357 	 * 
       
   358 	 */
       
   359 	public Control getControl(String aControlType) {
       
   360 		if (aControlType == null) {
       
   361 			throw new IllegalArgumentException("argument is null");
       
   362 		}
       
   363 		
       
   364 		String controlType = aControlType;
       
   365 
       
   366         // check if package name exists
       
   367         if (controlType.indexOf(".") == -1)
       
   368         {
       
   369             // add package name
       
   370             controlType = CONTROL_DEFAULT_PACKAGE + aControlType;
       
   371         }
       
   372         Control control = (Control)iControls.get(controlType);
       
   373         // If control does not exists with default name, check if there is
       
   374         // is a control with same type ( extends the given class name ).
       
   375 		if (control == null) {
       
   376 			try {
       
   377 				// try to create class for control
       
   378 				Class controlClass = Class.forName(controlType);
       
   379 				Enumeration elements = iControls.elements();
       
   380 				// search if any control is same type that requested control
       
   381 				while (elements.hasMoreElements()) {
       
   382 					Control tmpControl = (Control) elements.nextElement();
       
   383 					if (controlClass.isInstance(tmpControl)) {
       
   384 						// control is found
       
   385 						control = tmpControl;
       
   386 					}
       
   387 				}
       
   388 			} catch (ClassNotFoundException cnfe) // the class could not be
       
   389 													// found
       
   390 			{
       
   391 				// Exception is ignored and null is returned from this method
       
   392 			} catch (Error e) // the function failed for any other reason.
       
   393 			{
       
   394 				// Error is ignored and null is returned from this method
       
   395 			}
       
   396 		}
       
   397         return control;
       
   398 	}
       
   399 	/**
       
   400 	 * Returns all the control associated with this player 
       
   401 	 */
       
   402 	public Control[] getControls() {
       
   403 		Control control[]= new Control[iControls.size()];
       
   404 		Enumeration enumeration= iControls.elements();
       
   405 		byte index=0;
       
   406 		while(enumeration.hasMoreElements()){
       
   407 			control[index++]=(Control)enumeration.nextElement();
       
   408 		}
       
   409 		return control;
       
   410 	}
       
   411 	/**
       
   412 	 * 
       
   413 	 */
       
   414 	public void setLoopCount(int aCount){
       
   415 		super.setLoopCount(aCount);
       
   416 		iTotalLoopCount=aCount;
       
   417 	}
       
   418 	/**
       
   419      * From PlayerBase
       
   420      * @see PlayerBase
       
   421      */
       
   422 	public long setMediaTime(long aNow) throws MediaException {
       
   423 		long now = super.setMediaTime(aNow);
       
   424 		int totalFrames = iImageData.length;
       
   425 		int totalTime = 0;
       
   426 		for (int i = 0; i < totalFrames; i++) {
       
   427 			if (now < totalTime) {
       
   428 				iFrameindex=i;
       
   429 				break;
       
   430 			}
       
   431 			totalTime += iImageData[i].delayTime * 10000;
       
   432 		}
       
   433 		return totalTime;
       
   434 	}
       
   435 	//////////////////////////////////////////////////////////////////////////////////////
       
   436 	// Following functions are for internal use, and not exposed to MIDlet developer//////
       
   437 	/////////////////////////////////////////////////////////////////////////////////////
       
   438 	/**
       
   439 	 * 
       
   440 	 */
       
   441 	private void doStart(){
       
   442 		
       
   443 	}
       
   444 	
       
   445 	
       
   446     /**
       
   447 	 * This function is responsible for creating all controls and adding it into Controls hashtable.
       
   448 	 */
       
   449 	private void pupulateControl(){
       
   450 		final String DEBUG_STR="AnimationPlayer::pupulateControl()";
       
   451 		System.out.println(DEBUG_STR+"+");
       
   452 		VideoControl videoControl= new VideoControl(this);
       
   453 		FramePositioningControl fpc= new FramePositioningControl(this);
       
   454 		StopTimeControl stc= new StopTimeControl(this);
       
   455 		RateControl rc= new RateControl(this);
       
   456 		try {
       
   457 			addControl(videoControl, fVideoControl);
       
   458 			addControl(fpc, fFramePositioningControl);
       
   459 			addControl(stc, fStopTimeControl);
       
   460 			addControl(rc,fRateControl);
       
   461 		} catch (MediaException e) {
       
   462 			// TODO Auto-generated catch block
       
   463 			e.printStackTrace();
       
   464 		}
       
   465 		System.out.println(DEBUG_STR+"-");
       
   466 	}
       
   467 	/**
       
   468 	 * This function initialize iControl and iDisplay object if it is null,
       
   469 	 * otherwise return immediately.
       
   470 	 * 
       
   471 	 * In case of Canvas, eSWT control will be returned immediately from VideoControl(vc.getControl()), 
       
   472 	 * but in case of CustomItem we need to keep polling, eSWT doesn't return the control for CustomItem 
       
   473 	 * until CustomItem is appended to Form.      
       
   474 	 */
       
   475 	
       
   476 	private void initialize() {
       
   477 		final String DEBUG_STR = "AnimationPlayer::initialize()";
       
   478 		System.out.println(DEBUG_STR + "+");
       
   479 		System.out.println(DEBUG_STR + " Control is " + iControl
       
   480 				+ " display is " + iDisplay);
       
   481 		if (iControl == null || iDisplay == null) {
       
   482 			VideoControl vc = (VideoControl) getControl(fVideoControl);
       
   483 			iDisplay = vc.getiDisplay();
       
   484 			// in case of CustomItem,
       
   485 			while ((iControl = vc.getControl()) == null) {
       
   486 				try {
       
   487 					Thread.sleep(100);
       
   488 				} catch (InterruptedException e) {
       
   489 					e.printStackTrace();
       
   490 				}
       
   491 			}
       
   492 		}
       
   493 		System.out.println(DEBUG_STR + "-");
       
   494 	}
       
   495 	
       
   496 	/**
       
   497 	 * This function will be called from setDisplaySize(int width, int height) of animation/VideoControl class
       
   498 	 * When MIDlet developer will try to alter the size of the image 
       
   499 	 * @param width : to be set of the video(Animated GIF) 
       
   500 	 * @param height : height to be set of video(Animated GIF) 
       
   501 	 */
       
   502 	void updateImageData(int width, int height){
       
   503 		final String DEBUG_STR= "AnimationPlayer::updateImageData(int width, int height)";
       
   504 		System.out.println(DEBUG_STR+"+");
       
   505 		int noOfFrames= iImageData.length;
       
   506 		for(int i=0;i<noOfFrames;i++){
       
   507 			iImageData[i]=iImageData[i].scaledTo(width, height);
       
   508 		}
       
   509 		iImage=new Image(iDisplay, iImageData[0]);
       
   510 		System.out.println(DEBUG_STR+"-");
       
   511 	}
       
   512 	
       
   513 	/**
       
   514 	 * This function will be called from getSnapshot() function of VideoControl class 
       
   515 	 * to get the snap shot of the video 
       
   516 	 * 
       
   517 	 * @param format
       
   518 	 */
       
   519 	// This function is not implemented fully  
       
   520 	int[] getCurrentFrame(String format){
       
   521 		final String DEBUG_STR="AnimationPlayer::getCurrentFrame()";
       
   522 		System.out.println(DEBUG_STR+"+");
       
   523 		ImageData currentFrameImageData=iImage.getImageData();
       
   524 		int data[][]= new int[currentFrameImageData.height][currentFrameImageData.width];
       
   525 		System.out.println("Width of the current Image is "+data[0].length+" height "+data.length);
       
   526 		
       
   527 		int imageWidth=data[0].length;
       
   528 		int imageHeight=data.length;
       
   529 		System.out.println("Image Width "+imageWidth+", "+currentFrameImageData.width+" height "+imageHeight+", "+currentFrameImageData.height);
       
   530 		
       
   531 		for(int i=0;i<imageHeight;i++){
       
   532 			currentFrameImageData.getPixels(0, i, imageWidth, data[i], 0);
       
   533 			System.out.println(DEBUG_STR+"=========>"+data[i]);
       
   534 		}
       
   535 		System.out.println(DEBUG_STR+"After reading all pixel value");
       
   536 		int[] byteArray=new int[imageWidth*imageHeight];
       
   537 		//int dataLength=data.length;
       
   538 		
       
   539 		for(int i=0;i<imageHeight;i++){
       
   540 			System.arraycopy(data[i], 0, byteArray, i*imageWidth, imageWidth);
       
   541 		}
       
   542 		System.out.println(DEBUG_STR+"After merging all array into single array ");
       
   543 		System.out.println(DEBUG_STR+"-"+byteArray+">>>>>"+byteArray.length);
       
   544 		return byteArray;
       
   545 	}
       
   546 	
       
   547 	/**
       
   548 	 * Returns Point object, which contains the width and height of the image
       
   549 	 * Called from VideoControl to get the image width and height, 
       
   550 	 * so that Item will be created exactly of same dimension 
       
   551 	 */
       
   552 	org.eclipse.swt.graphics.Point getImageDimension(){
       
   553 		return new org.eclipse.swt.graphics.Point(iImageData[0].width, iImageData[0].height);  
       
   554 	}
       
   555 	
       
   556 	/**
       
   557 	 * This returns the imageData array, 
       
   558 	 * called from FramePositioningControl class to calculate the frame time 
       
   559 	 */
       
   560 	ImageData[] getImageData(){
       
   561 		return iImageData;
       
   562 	}
       
   563 	
       
   564 	/**
       
   565 	 * 
       
   566 	 * @param aDisplayLocation x,y coordinate where image is to be displayed 
       
   567 	 */
       
   568 	void setDisplayLocation(int aX, int aY){
       
   569 		iDisplayLocation=new Point(aX,aY);
       
   570 	}
       
   571 	
       
   572 	/**
       
   573 	 * @return the position of the image to be displayed 
       
   574 	 */
       
   575 	Point getiDisplayLocation() {
       
   576 		return iDisplayLocation;
       
   577 	}
       
   578 	/**
       
   579 	 * Called from VideoControl to get the dimension of original image size 
       
   580 	 * @return
       
   581 	 */
       
   582 	Point getSourceDimension() {
       
   583 		return iSourceDimension;
       
   584 	}
       
   585 
       
   586 	/**
       
   587 	 * @return the iPlayerListenerImpl
       
   588 	 */
       
   589 	PlayerListenerImpl getiPlayerListenerImpl() {
       
   590 		return iPlayerListenerImpl;
       
   591 	}
       
   592 }