You Are Here:

Community: Developer Discussion Boards

#1 Old Lightbulb camera window resize ??????? - 2009-03-18, 09:39

Join Date: Sep 2008
Posts: 24
akshaychaudhari
Offline
Registered User
hi ,
i want to resize the window that appears while capturing photo??
pls tell me how to do that ...........
Reply With Quote

#2 Old Re: camera window resize ??????? - 2009-03-19, 10:51

Join Date: Dec 2007
Posts: 46
ghravikumar
Offline
Registered User
Are you attempting to resize the capturing window from a MIDlet or with the default application?

BR
Ravikumar
Reply With Quote

#3 Old Re: camera window resize ??????? - 2009-03-19, 11:05

Join Date: Sep 2008
Posts: 24
akshaychaudhari
Offline
Registered User
yes i am using MIDlet
Reply With Quote

#4 Old Thumbs up Re: camera window resize ??????? - 2009-03-19, 18:22

Join Date: Sep 2008
Posts: 1,195
Location: DELHI
Send a message via Yahoo to jitu_goldie
jitu_goldie's Avatar
jitu_goldie
Offline
Forum Nokia Champion
Hi,

what r u using for displaying videocamera(video control) form or canvas. with form resizing of videocontrol is not seen by me ever but u can resize the videocontrol over canvas with the help of setDisplaySize() function of VideoControl interface.

if this is not ur problem than forgive me to misunderstand ur problem and pls describe ur problem in detail.

thanks,
jitu_goldie..


thanks,
jitu_goldie..

KEEP TRYING..
Reply With Quote

#5 Old Post Re: camera window resize ??????? - 2009-03-20, 07:33

Join Date: Sep 2008
Posts: 24
akshaychaudhari
Offline
Registered User
i am using following code....

import javax.microedition.midlet.*;

//import java.util.TimeZone;
import javax.microedition.lcdui.*;
import java.util.*;
import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.media.control.VideoControl;
import javax.microedition.media.MediaException;

import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;

import java.io.OutputStream;
import java.io.IOException;

public class Midlet extends MIDlet implements CommandListener {

private Display display;

// Form where camera viewfinder is placed
private Form cameraForm;

// Command for capturing image by camera and saving it.
// Placed in cameraForm.
private Command cmdCapture;
// Command for exiting from midlet. Placed in cameraForm.
private Command cmdExit;

// Player for camera
private Player player;
// Video control of camera
private VideoControl videoControl;

// Alert to be displayed if error occurs.
private Alert alert;

/**
* Constructor.
*/
public Midlet() {
InitializeComponents();
}

/**
* Initializes components of midlet.
*/
private void InitializeComponents() {
display = Display.getDisplay(this);

if(checkCameraSupport() == false) {
showAlert("Alert", "Camera is not supported!", null);
return;
}

try {
createCameraForm();
createCamera();
addCameraToForm();
startCamera();
} catch(IOException ioExc) {
showAlert("IO error", ioExc.getMessage(), null);
} catch(MediaException mediaExc) {
showAlert("Media error", mediaExc.getMessage(), null);
}
}

/**
* Creates and returns form where the camera control will be placed.
*/
private void createCameraForm() {
// Create camera form
cameraForm = new Form("Camera");
// Create commands for this form
cmdCapture = new Command("Capture", Command.OK, 1);
cmdExit = new Command("Exit", Command.EXIT, 0);
// Add commands to form
cameraForm.addCommand(cmdCapture);
cameraForm.addCommand(cmdExit);
// Set midlet as command listener for this form
cameraForm.setCommandListener(this);
}

/**
* Check camera support.
* @return true if camera is supported, false otherwise.
*/
private boolean checkCameraSupport() {
String propValue = System.getProperty("supports.video.capture");
return (propValue != null) && propValue.equals("true");
}

/**
* Creates camera control and places it to cameraForm.
* @throws IOException if creation of player is failed.
* @throws MediaException if creation of player is failed.
*/
private void createCamera() throws IOException, MediaException {
player = Manager.createPlayer("capture://devcam1");
player.realize();
player.prefetch();

videoControl = (VideoControl)player.getControl("VideoControl");
}

/**
* Adds created camera as item to cameraForm.
*/
private void addCameraToForm() {
cameraForm.append((Item)videoControl.
initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, null));
}

/**
* Start camera player
* @throws IOException if starting of player is failed.
* @throws MediaException if starting of player is failed.
*/
private void startCamera() throws IOException, MediaException {
if(player.getState() == Player.PREFETCHED) {
player.start();
}
}

/**
* Saves image captured by camera.
*/
private void captureAndSaveImage() {
FileConnection file = null;
OutputStream outStream = null;

try {
if(checkPngEncodingSupport() == false) {
throw new Exception("Png encoding is not supported!");
}

// Capture image
byte[] capturedImageData =
videoControl.getSnapshot("encoding=jpg");

// Get path to photos folder.
String dirPhotos = System.getProperty("fileconn.dir.photos");
if(dirPhotos == null) {
throw new Exception("Unable get photos folder name");
}

Calendar calendar = Calendar.getInstance();
//calendar.setTimeInMillis(System.currentTimeMillis());
String date = Integer.toString(calendar.get(calendar.DATE));
String time = Integer.toString(calendar.get(calendar.SECOND));
String hour = Integer.toString(calendar.get(calendar.HOUR));
String minute = Integer.toString(calendar.get(calendar.MINUTE));
String milsecond = Integer.toString(calendar.get(calendar.MILLISECOND));
// Date time = getDate();
String fileName = dirPhotos + date + hour + minute + time + milsecond + ".png";
// Open file
file = (FileConnection)Connector.open(fileName,
Connector.READ_WRITE);
// If there is no file then create it
if(file.exists() == false) {
file.create();
}
// Write data received from camera while making snapshot to file
outStream = file.openOutputStream();
outStream.write(capturedImageData);

showAlert("Info", "Image is saved in " + fileName, cameraForm);

} catch(IOException ioExc) {
showAlert("IO error", ioExc.getMessage(), cameraForm);
} catch(MediaException mediaExc) {
showAlert("Media error", mediaExc.getMessage(), cameraForm);
} catch(Exception exc) {
showAlert("Error", exc.getMessage(), cameraForm);
} finally {
// Try to close file
try {
if(outStream != null) {
outStream.close();
}
if(file != null) {
file.close();
}
} catch(Exception exc) {
// Do nothing
}
}
}

/**
* Checks png encoding support
* @return true if png encoding is supported false otherwise.
*/
private boolean checkPngEncodingSupport() {
String encodings = System.getProperty("video.snapshot.encodings");
return (encodings != null) && (encodings.indexOf("png") != -1);
}

/**
* From MIDlet.
* Signals the MIDlet that it has entered the Active state.
*/
public void startApp() {
if ( videoControl != null ) {
display.setCurrent(cameraForm);
}
}

/**
* From MIDlet.
* Signals the MIDlet to enter the Paused state.
*/
public void pauseApp() {
// TODO: pause player if it is running.
}

/**
* Performs exit from midlet.
*/
public void exitMIDlet() {
notifyDestroyed();
}

/**
* Shows alert with specified title and text. If next displayable is not
* specified then application will be closed after alert closing.
* @param title - Title of alert.
* @param message - text of alert.
* @param nextDisp - next displayable. Can be null.
*/
private void showAlert(String title, String message, Displayable nextDisp) {
alert = new Alert(title);
alert.setString(message);
alert.setTimeout(Alert.FOREVER);

if(nextDisp != null) {
display.setCurrent(alert, nextDisp);
} else {
display.setCurrent(alert);
alert.setCommandListener(this);
}
}

/**
* From MIDlet.
* Signals the MIDlet to terminate and enter the Destroyed state.
*/
public void destroyApp(boolean unconditional) {
if(player != null) {
player.deallocate();
player.close();
}
}

/**
* From CommandListener.
* Indicates that a command event has occurred on Displayable displayable.
* @param command - a Command object identifying the command.
* @param displayable - the Displayable on which this event has occurred.
*/
public void commandAction(Command command, Displayable displayable) {
// Handles "Capture image" command from cameraForm
if(command == cmdCapture) {
captureAndSaveImage();
}
// Handles "exit" command from forms
if(command == cmdExit) {
exitMIDlet();
}
// Handle "ok" command from alert
if(displayable == alert) {
exitMIDlet();
}
}
}
Reply With Quote

#6 Old Thumbs up Re: camera window resize ??????? - 2009-03-20, 17:56

Join Date: Sep 2008
Posts: 1,195
Location: DELHI
Send a message via Yahoo to jitu_goldie
jitu_goldie's Avatar
jitu_goldie
Offline
Forum Nokia Champion
hi buddy,
u r using form to display the videocontrol. As i already said that i havent seen ever any code or example in which resizing of wideocontrol is done. If u wanna resizing the videocontrol then pls use canvas for this task.


thanks,
jitu_goldie..


thanks,
jitu_goldie..

KEEP TRYING..
Reply With Quote

#7 Old Re: camera window resize ??????? - 2009-03-23, 04:35

Join Date: May 2007
Posts: 347
Location: Mexico D.F
rdrincon's Avatar
rdrincon
Offline
Forum Nokia Expert
Hello,
use the setDisplaySize method of your VideoControl


Quote:


void setDisplaySize(int width, int height) throws MediaException

Resize the video image.
If the video mode is set to USE_DIRECT_VIDEO, setting the size of the video will not affect the size of the GUI object that the video is displayed. If the video is scaled to beyond the size of the GUI object, the video will be clipped.

If the video mode is set to USE_GUI_PRIMITIVE, Scaling the video will also scale the GUI object.

The actual scaling algorithm is left up to the underlying implementation. If the dimensions of the requested display size are smaller than the dimensions of the video clip, some implementations may choose to merely clip the video while other implementations may resize the video.

If the dimensions of the requested display size are bigger than the dimensions of the video clip, some implementations may resize the video while others may leave the video clip in the original size and just enlarge the display region. It is left up to the implementation where the video clip is placed in the display region in this instance (i.e., it can be in the center of the window or in a corner of the window).


Parameters:
width - Desired width (in pixels) of the display window
height - Desired height (in pixels) of the display window

Please don't forget to make the VideoControl visible, several people having trouble for not doing this.

Quote:
videoControl.setVisible(true);


:Ruben
Reply With Quote

#8 Old Re: camera window resize ??????? - 2009-04-06, 11:58

Join Date: Feb 2009
Posts: 37
manish88
Offline
Registered User
HI i also having same problem while capturing Image
but as u said i resize the camera window it work fine
But the size of image is same as it was before i want to reduce size of image also
Thanks..........-
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Python for S60 1.4.0 released jplauril Python 43 2009-05-24 10:22
Nokia N-Series Complete Model Line-Up Dopod General Discussion 6 2008-07-22 21:16
Problem Creating Window Using RWindow and putting More controls on it er_gps212 Symbian User Interface 0 2005-10-28 07:22
About window views thodime_guru Symbian User Interface 1 2004-06-17 19:00

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ