Picture taken with the camera...
Hi all
I am currently facing a lot of problems to use the camera. After days and days of trying to change/adapt my code, you are my last hope...
What I want to do is:
- Departure from camera
- The take a snapshot
- Resizing in my application
- Store in the FET (don't cause me problems)
Here is part of my code:
- Beginning camera & look the file system
public CameraBlackBerry() { // invoking camera UiApplication.getApplication().addFileSystemJournalListener(this); Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, new CameraArguments()); }
2 get path to the new image and transfer to another class
public void fileJournalChanged() { AIDOO.debug(">>>>>>>> FS MODIFIED !!!"); Application app = UiApplication.getApplication(); app.removeFileSystemJournalListener(this); long USN = FileSystemJournal.getNextUSN(); for (long i = USN - 1; i >= 0; i--) { System.out.println(">>>>>>>> FS MODIFIED !!! : " + i); FileSystemJournalEntry entry = FileSystemJournal.getEntry(i); if (entry.getEvent() == FileSystemJournalEntry.FILE_ADDED) { path = entry.getPath(); if (path.endsWith(".jpg")) {// Try to kill camera app here by injecting esc. HAD to remove condition '&& path.indexOf("IMG") >= 0' because changed in OS6 //#ifdef DebugMode AIDOO.debug(">>>>>>>> Found a file added ending with jpg @ :" + path); //#endif // Get out of camera app EventInjector.KeyEvent inject = new EventInjector.KeyEvent(EventInjector.KeyEvent.KEY_DOWN, Characters.ESCAPE, 0); inject.post(); inject.post(); app.requestForeground(); AIDOO.currentCameraBlackBerry = null; new CameraBlackBerryFileHandler(path); break; } } if (entry == null) { // we didn't find an entry. break; } } }
3. how to get a FileConnection
private FileConnection openFile() { try { FileConnection file = (FileConnection) Connector.open("file://" + path); if (file != null) { boolean fileExists = file.exists(); int existCount = 0; while (!fileExists && existCount < 50) { AIDOO.debug("fileExists sleeping for 100 msecond"); Thread.sleep(100); fileExists = file.exists(); existCount++; } if (existCount < 50 && fileExists) { return file; } else { return null; } } else { return null; } } catch (InterruptedException ex) { alerta = new Alert(Lng.getString(Lng.a_alert), "InterruptedException while opening picture connection : " + ex.getMessage() + " " + ex.getClass() + " path :" + path, null, null); AIDOO.handleError("Exception while opening picture connection", ex); return null; } catch (IllegalArgumentException ex) { alerta = new Alert(Lng.getString(Lng.a_alert), "IllegalArgumentException while opening picture connection : " + ex.getMessage() + " " + ex.getClass() + " path :" + path, null, null); AIDOO.handleError("Exception while opening picture connection", ex); return null; } catch (ConnectionNotFoundException ex) { alerta = new Alert(Lng.getString(Lng.a_alert), "ConnectionNotFoundException while opening picture connection : " + ex.getMessage() + " " + ex.getClass() + " path :" + path, null, null); AIDOO.handleError("Exception while opening picture connection", ex); return null; } catch (IOException ex) { alerta = new Alert(Lng.getString(Lng.a_alert), "IOException while opening picture connection : " + ex.getMessage() + " " + ex.getClass() + " path :" + path, null, null); AIDOO.handleError("Exception while opening picture connection", ex); return null; } }
4 getting the stream
private DataInputStream tryAccessingImage(FileConnection file) { DataInputStream is = null; nbBytes = 0; try { is = file.openDataInputStream(); } catch (IOException ex) { return null; } if (is != null && file.canRead()) { try { nbBytes = file.fileSize(); isAvailNbBytes = is.available(); int unreadableCount = 0; while (nbBytes <= 0 && unreadableCount < 50) { AIDOO.debug("fileSize problem, sleeping for 100 msecond"); Thread.sleep(100); nbBytes = file.fileSize(); unreadableCount++; } if (unreadableCount < 50) { return is; } else { return null; } } catch (InterruptedException ex) { String problem = Lng.getString(Lng.pic_couldnt_be_stored) + "(2) " + ex.getMessage() + "/ InterruptedException can read file : " + file.canRead() + " " + nbBytes + "bytes / " + path; append(problem, imageProblem); alerta = new Alert(Lng.getString(Lng.a_alert), problem, null, null); return null; } catch (IOException ex) { String problem = Lng.getString(Lng.pic_couldnt_be_stored) + "(2) " + ex.getMessage() + "/ IOException2 can read file : " + file.canRead() + " " + nbBytes + "bytes / " + path; append(problem, imageProblem); alerta = new Alert(Lng.getString(Lng.a_alert), problem, null, null); return null; } } else { alerta = new Alert(Lng.getString(Lng.a_alert), Lng.getString(Lng.pic_couldnt_be_stored) + "(2) / InterruptedException can read file : " + file.canRead() + " " + nbBytes + "bytes / " + path, null, null); return null; } }
5 reading the stream
private byte[] readingImage(DataInputStream is) { byte[] raw = new byte[(int) nbBytes]; isReadBytes = -2; // -2 to differ from eventual -1, 0 or n (positive) returned by read() try { isReadBytes = is.read(raw); return raw; } catch (IOException ex) { String problem = Lng.getString(Lng.pic_couldnt_be_stored) + "readingImage " + ex.getMessage() + "/ IOException1 can read file : " + nbBytes + "bytes / " + path; append(problem, imageProblem); alerta = new Alert(Lng.getString(Lng.a_alert), problem, null, null); return null; } }
6 then I do the following
try { is.close(); screenWidth /= 4; screenWidth *= 3; screenHeight /= 4; screenHeight *= 3; append("resizing image", imageBlank16); raw = resizeImage(raw, 640, 480); append("resize for preview image", imageBlank16); byte rawPreview[] = resizeImage(raw, screenWidth, screenHeight); AIDOO.debug("ok here"); append("creating preview image", imageBlank16); imagePreview = Image.createImage(rawPreview, 0, rawPreview.length); AIDOO.debug("ok here2"); String devinceInfo = DeviceInfo.getSoftwareVersion(); AIDOO.debug(devinceInfo); AIDOO.debug("ok here3"); //#if !BlackBerry_OS_46 && !BlackBerry_Older_than_46 //raw = resizeImage(raw); nbBytes = raw.length; //#endif if (nbBytes > CAMERA_IMAGE_MAX_SIZE) { alerta = new Alert(Lng.getString(Lng.a_alert), Lng.getString(Lng.pic_size_is_too_large) + " : " + nbBytes, null, null); System.out.println("error 2 after insert"); returnValue = false; } } catch (IOException ioe) { alerta = new Alert(Lng.getString(Lng.a_alert), "IOException : " + ioe.getMessage() + "available Bytes : " + nbBytes, null, null); AIDOO.handleError("IO problem while saving picture 0", ioe); System.out.println("error 2 after insert"); returnValue = false; }
7 Behold my image resizing function
private byte[] resizeImage(byte[] image, int width, int height) { AIDOO.debug("Start of image resizing"); Bitmap bmp1 = null, bmp2 = null; try { bmp1 = Bitmap.createBitmapFromBytes(image, 0, -1, 1); bmp2 = new Bitmap(width, height); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("exception while createBitmapFromBytes()" + ex.getMessage() + "isAvailNbBytes = " + isAvailNbBytes + " isReadBytes = " + isReadBytes + " length = " + image.length + " nbBytes = " + nbBytes + " image = " + image); } AIDOO.debug("Scale into"); bmp1.scaleInto(bmp2, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_TO_FIT); AIDOO.debug("End of Scale into"); JPEGEncodedImage encoded = JPEGEncodedImage.encode(bmp2, 90); return encoded.getData(); }
My problems are:
1. sometimes the image is cropped, this size (w/h) is OK, but for some strange reason it is not all the time. There is always a large black area at the bottom of the image. It seems that something has not been correctly readen.
2. sometimes I had an IllegalArgumentException in createBitmapFromBytes() function.
I read a lot of posts that talk about these problems, but I have found no solution.
Is it so hard to take a picture of the camera and display it?
Anyone have a good example/code example on how to handle this?
Thank you for your support and for reading me
(Sorry for my English )
I suspect that these problems are caused by the fact that the earpiece of the paper you use is told on the file being written until the writing is actually completed.
I think that Ihad this problem in an application that I wrote and to get around it, rather than process the image in the JournalListener, I actually got the JournalListener to save the file created in the method of invocation of the "onExposed" screen, I checked to see if the name of the file has been updated and if so , I would treat it then. onExposed is not get leads until the camera application has closed at this time, according to me, that it is save saying that the file has been saved.
I think that there are other options. For example, you could start a thread check the size of the file and if it does not grow after a second or two, you might assume that the writing was completed.
In all cases, this is where I would start looking for the problem.
Tags: BlackBerry Developers
Similar Questions
-
I downloaded Adobe camera raw 8.4 so that I can open raw files with pictures taken with the camera Sony a6000. However, it does not open images in camera raw. What can I do?
I suggest you please update Camera Raw 9.1.1: Camera Raw of Adobe Photoshop CC and CS6 Installer
Once done, launch Photoshop and click Help > about plug-in > Camera Raw.
And check the version of Camera Raw, you see there, it should be the most recent.
-
Link to pictures taken with the camera.
Hello
I am currently working with the Simulator and took a picture with the camera I want to display in the widget or even better access to try to send it to a web service.
If I do the following Java script:
var path = "file:///store/home/user/pictures/IMG00042-20110121-1222.jpg";
Alert (BlackBerry.IO.file.Exists (Path));
Result is an alert reading 'real' I expect so he can certainly see the file at this location. However when I try and set a value SRC tags local image for the above path I just get a broken showing image. If I try to read the file using:
blackberry.io.file.readFile (path, handleOpenedFile);
If you are wanting to use the image in a tag you will have to the white list of the original file in your config.xml file:
-
Small blue wavy lines on pictures taken with the iPhone
These blue wavy lines appeared when I take pictures with my front & rear in front of the camera of the iPhone 6. They have always been there and there doesn't seem to be any damage to one of the glasses. I know that they are small but are easily noticeable especially when zoomed in. How they are caused? apple can fix it? I have found no issue similar to this on the web.
Try to take a screenshot , while in the camera. If the blue lines appear then its either something on or under your goal. You can try to clean it up, but if not, you will need to consider in or contact Apple for service.
-
Where are the location of metadata stored in pictures taken with an iOS device?
I just follow me back from a trip with a lot of pictures taken with a couple of the iPhone as a digital camera. Pictures taken with the iOS for most devices have locations associated with them, as evidenced by the dialog box 'Get Info' in Photos for Mac. They show well on a card and are correctly associated with keywords of the location (for example, "Sierra National Forest, northeast of Fresno County, United States of America"). But I can't know where the coordinates are stored. There is nowhere to search Photos for Mac that will give me the real coordinates. Also open images in preview does not display a GPS tab in the 'Détails' box how will be my camera equipped with GPS. And finally the search all metadata in Photoshop or Adobe Bridge also will not show all the details or any other type of geographic information. I just checked my old version of iPhoto (9.6.1) and she won't show also all location information.
Photos for Mac will display basic information, but I can't find where this happens. Any ideas?
If you don't see any GPS information in the Inspector of Preview window, you are probably stripping while dragging or by exporting to office. Try dragging the image from Photos while pressing the Option key.
-
When taking picture with the light in the background with the camera back from my iPhone more than 6 s, there is a clear blue colour square (a bit like a reflection of the light) will appear.
someone has an idea of what's going on?
The blue square is the area of the camera is in point and exposure on.
Tap on the area actually taking a picture of. For example, if you take a photo of someone int eh the room and the bottom is very light (or dark), tap on the face of the person to turn to that.
See it-> http://iphonephotographyschool.com/how-to-use-iphones-camera-app/
-
Take pictures with the camera on the T410s
Is it possible to take pictures with the camera of the T410s, and is there any software related to this? I tried everything I can think of but no luck. Are there instructions on how to use this camera somewhere?
I would really appreciate any advice or assistance. Thank you!
Yawcam?
-
Hi I godt 2 Questions: 1) my Adobe PhotoShop elements 10.0 for MAC cannot read taken with the new Canon 7 d Mark II camera RAW files. (2) my Photoshop Elements changed from Danish language of German language, how do I put this back?
1. you have cr 8.7 or better: use the dng converter or upgrade your pse in v. 13.
-
Unable to work with the camera on laptop
Original title: camera
my camera on my laptop does not work.
It works through skyping, but I want to take pictures and do the videoes but his does not work
Hi r.,
Please answer a few questions to refine the question.
1. are you referring to photo App? What is the situation when you launch photo App?
2. do you receive any error messages?
3. What is the brand and model of the laptop?
As you said that you were able to work with the camera when using Skype app, there is a problem with the permission of the camera app to use the construction in camera.
If the camera application opens, then follow the steps mentioned below:
a. press Windows + C on your keyboard to open the bar of charms.
b. Select the settings option.
c. Select permissions .
d. snap it allow this application to access to your: Webcam and Microphone option.
e. close the application by pressing Alt + F4 on your keyboard.
f. open the camera app and check the results.If the problem persists, then I suggest you to run Windows 8 Troubleshooting App to diagnose and resolve the problem.
Hope this information helps.
-
Cannot see the preview of my photos taken with the Sony A7R II even after software update.
Even after the the Lightroom update, I still don't see the preview of my photos taken with the Sony A7R II even after software update. Need help please.
Hi Joas,
Sony A7R II files are not supported in Lightroom 5.
You need at least version 6.1.1 or CC2015.1.1 to access these files: supported by Adobe Camera Raw devices
You can upgrade your program of Lightroom or Adobe DNG Converter allows you to convert raw files to DNG and import them into Lightroom.
Kind regards
Claes
-
Question:
I use Photoshop CS5 version 12.1. Photos I take in Camera Raw with my Canon 60 d are visible and can be worked, but those taken with my Canon 70 d are not. What can I do to be able to view and work on Camera Raw photos taken with both cameras? Y at - it a plug-in that I can use that will allow me to display and work on photos of 70 d and my photos of the 60 d? Helpful suggestions are appreciated.
The 70 d has not supported until the Camera Raw version 8.2:
Devices supported by Adobe Camera Raw
PS Camera Raw versions of CS5 ended with 6.7:
Camera Raw plugin and Adobe application compatibility
You have two options: upgrade to at least Photoshop CC or CS6 or get the free DNG Converter to convert your RAWs 70 d DNG for use in CS5. The last option will always require an additional step.
Digital Negative (DNG), Adobe DNG Converter | Adobe Photoshop CC
-
recently updated the Canon mark II, mark iii, and the images taken of the mark iii will not make previews in bridge. Bridge will show previews for the images taken with the mark ii, but not the mark iii. I have adobe cc and am using camera raw 9.2. I checked the updates and it is said that there is not. I also tried to purge the cache several times and that didn't work either. Any help with this would be so appreciated its driving me crazy!
Take a look at this: generic icons | Files camera raw | Adobe Bridge
-
whenever I have to video chat with anyone with front camera on they won't listen to me. Even when I record with fromt camera microphone does not work with the camera back, everything works correctly and even with siri, I can't talk more but when I take a call they can hear perfectly
Get help with microphones on your iPhone, iPad and iPod touch...
-
I bought a Sony handy cam, the disc that came with the camera does not work on my computer and I can't even play videos from my camera through my screen. I want to be able to download and edit with music and cut off the stuff, but I can't do anything yet. Help, please
I bought a Sony handy cam, the disc that came with the camera does not work on my computer and I can't even play videos from my camera through my screen. I want to be able to download and edit with music and cut off the stuff, but I can't do anything yet. Help, please
Your question has been marked as answered, only you do not mark it as such.
I feel compelled to ask whether and how you solved your problem?
The marked answer * not * have one you used and for the benefit of those who might ask the same question in the future it is better the original poster mark their own answers, in my opinion.
-
Add to catches taken with the cutting tool
Original title:
cutting tool options
is it possible to add a date to the tinsmith shear taken with the cutting tool?
UD
Other than in the name no file properties. When you save the file, it will be time and date of today.
Maybe you are looking for
-
It's the second s30 I've owned (first just died)... as a first step, this second o.k saved one but now when I press the record button nothing happens... it is equipped with a max ram32gb sdhc card that I formatted... Any suggestions?
-
FPGA FIFO real-time error-61206
I used this white paper as a base for my code. My FPGA look like: And my time real-time (RT): I am using a cRIO-9022 and now just trying to get the foundations buried for my project. The problem is that the side FPGA works well but environmental RT t
-
Bought a charger car Macally, model USBCIG2, that lists all compatible iPod and iPhone models. My question is that will work with my Clip charger, it is standard 5v usb output. MacAlly also has a model for Sansa, but good luck to find in a store. I
-
Wallpaper images load oversized cut about 1 "of the original photo.
As indicated, the background screen images are cut approximately 1 "autour. The original pictures are 1024 X 768 size. It seems as if the picture will leave the size of moose to 120%. Don't know if this has changed on the computer since I don't chang
-
When 8 7840 place will get a lollipop?
I was wondering as I thought and mine, dell said it must come preloaded. Nope... KitKat.