Nokia Asha from idea to app - Imaging

Post on 09-May-2015

7.236 views 3 download

description

Bring your ideas to life with the APIs and additional memory available for development on the Nokia Asha platform. Join this webinar to learn how much you can do in the area of imaging, with the Image Scaling API and the Image Processing API. You’ll also get detailed guidelines on how to work with the camerainterface and how to create special effects and filters.

Transcript of Nokia Asha from idea to app - Imaging

Asha Idea to App:ImagingMichael SamarinDirector, Developer Training and EvangelismFuturice

@MichaelSamarin

http://developer.nokia.com/asha/java/downloads

Manager

Player ControlData Source

javax.microedition.media

URLs“capture://image”“capture://video”

Live viewfinder VideoControlRecordControl

Form videoForm;Item videoItem;Player player;VideoControl videoControl;

player = Manager.createPlayer("capture://image");//player = Manager.createPlayer("capture://video");

player.prefetch();player.realize();player.start();videoControl = (VideoControl)player.getControl("VideoControl");videoItem = (Item)videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null);videoForm.append(videoItem);

byte[] imageBytes = videoControl.getSnapshot(null);

Image image = Image.createImage(imageBytes, 0, imageBytes.length);ImageItem imageItem = new ImageItem("", image, Item.PLAIN, "");videoForm.append(image);

String fileName = System.getProperty("fileconn.dir.photos”)+

"CapturedImage.jpg";FileConnection file = (FileConnection) Connector.open(fileName,

Connector.READ_WRITE);if (!file.exists()) file.create();

OutputStream out = file.openOutputStream();out.write(imageBytes);out.close();file.close();

byte[] imageBytes = videoControl.getSnapshot(null);//byte[] imageBytes = videoControl.getSnapshot(“width=640&height=480”);

Image image = Image.createImage(imageBytes, 0, imageBytes.length);ImageItem imageItem = new ImageItem("", image, Item.PLAIN, "");videoForm.append(image);

String fileName = System.getProperty("fileconn.dir.photos”)+

"CapturedImage.jpg";FileConnection file = (FileConnection) Connector.open(fileName,

Connector.READ_WRITE);if (!file.exists()) file.create();

OutputStream out = file.openOutputStream();out.write(imageBytes);out.close();file.close();

RecordControl recordControl;

recordControl = (RecordControl)player.getControl("RecordControl");

recordControl.setRecordLocation(System.getProperty("fileconn.dir.photos”) + "CapturedVideo.mp4");

recordControl.startRecord();

...

...

recordControl.stopRecord();

• Displaying live camera viewfinder;• Taking snapshot;• Recording video;

ImageScaler imageScaler = new ImageScaler(sourceImageFilePath, destinationFilePath);

imageScaler.addListener(this);

Integer requestId = new Integer(imageScaler.scaleImage(newWidth, newHeight, true));

. . .

public void scaleFinished(int requestId, int result)

...

MediaProcessor mediaProcessor = GlobalManager.createMediaProcessor(JPEG_TYPE);mediaProcessor.addMediaProcessorListener(this);...mediaProcessor.setInput(inputStream, MediaProcessor.UNKNOWN);...mediaProcessor.setOutput(byteArrayOutputStream);ImageEffectControl imageEffect =

(ImageEffectControl) mediaProcessor.getControl("javax.microedition.amms.control.imageeffect.ImageEffectControl");

imageEffect.setPreset("monochrome");imageEffect.setEnabled(true);mediaProcessor.start();

...public void mediaProcessorUpdate(MediaProcessor processor,

String event,Object eventData)

...

• Image Scaling API• Image Effects with APPS

© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft* as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION. *Microsoft refers to Microsoft Corp. and its affiliates, including Microsoft Mobile Oy, a wholly-owned subsidiary. The Nokia Devices and Services business is part of Microsoft Mobile Oy.

THANK YOU!