Image capture using CameraCapture - image

I am using a sample code from Microsoft windows SDK (CameraCapture, which is found in C:\Program Files\Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\CameraCapture) to capture image using windows mobile. The program save a image into a file, but I am interested to store the image into memory rather than any saving into storage.
any suggestions?

I don't have access to that particular sample but I assume that the project is using the CaptureCameraDialog class.
http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.forms.cameracapturedialog_members.aspx
Unfortunately using this class will only return the image path. You don't state why you need to save it in memory rather than on the disk but if your intention is to do some basic processing then you could just load it from the disk once captured.
using (CameraCaptureDialog cameraCapture = new CameraCaptureDialog())
{
cameraCapture.ShowDialog();
//get the name of the last image taken
string fileName = cameraCapture.FileName;
//Load the image from disk into our image object
Image image = new Bitmap(fileName);
}
A word of caution here. I believe when saved to disk the images will be in a compressed format, but when loaded into memory they will be uncompressed. It is very easy to cause an out of memory exception when working with images in the compact framework so I wouldn't recommend holding lots of images in memory at once especially if working with a hi resolution camera.

Related

Corona SDK, Lua

HELLLPPPPP!!!!! I am programming in Corona SDK, and I am trying to insert a backround image, with the following code ---local backround = display.newImage("bluebackround.jpg")--- But it does not want to show up in the simulator. It keeps giving me the following message in the output, ---Failed to find image 'bluebackround.jpg'---. My image is saved in the project folder. I am using Microsoft Windows software. I have done another project using Corona, and I inserted images completely fine. Anyone know what's going on with my code and how to fix it? Thank you very much in advance.
_W = display.contentWidth;
_H = display.contentHeight;
local image = display.newImageRect(--[["Name", width, heigth]] "bluebackround.jpg",_W, _H)
image.x = _W/2;
image.y = _H/2;
The your image need to be in the same folder as main.lua in your case. On the same level. Moreover, I think you misspell name of your image. You write 'bluebackround' without letter g in middle. So check name of the file.
From Corona documentation
Image guildelines:
Corona supports PNG and JPG format,
Images should not contain an embedded ICC profile,
Avoid progressive JPG files since they will take much longer to load.

How to control when image data is loaded into memory in Windows Store Apps?

When creating an image in a Windows Store App, how do you control when data is read from disk?
In WPF, you could control when an image was read from disk using BitmapCacheOptions. BitmapCacheOptions.OnDemand would postpone reading data from disk until the image data was actually needed. There were a few downsides to this:
IO costs often appeared as UI delays;
if a stream was used as the image source, then the stream could not be closed;
if a file was used as the image source, then the file was locked.
To address that problem you could use BitmapCacheOptions.OnLoad to read the image into memory immediately.
How do you control when image data is loaded into memory in Windows Store Apps?
WPF code would look something like this:
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.UriSource = path;
bitmapImage.EndInit();
bitmapImage.Freeze();
Edit - More info
WPA shows that getting an 8.8mb image onto the screen costs ~330ms. Of that, 170ms is spent on file IO (including 37ms for antivirus to check the file), and 160ms is spent on WIC decoding.
Any ideas how to control when the file IO happens or how to trigger WIC decoding?
(Right click and open in new tab to see full size)
For Windows Store Apps I suggest looking into the AccessCache APIs - http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.accesscache.aspx
Specifically the StorageApplicationPermissions class. With it you can add various storage items to be accessed.
Take a look at the FilePickerSample (or FileAccessSample) app for more information on how it can be used.

Images save to saved pics and retrieving back and displaying in my app in windows phone

Hello Friends I am New to WP7
i am working on small app now..
In that App i take one Pic from my camera and trying to save that in saved pictures with some name and i like to retrieve that Images and display again in my App Gallery screen
I am Using Pivot control for this app
in my first PivotItem Name is Gallery and second PivotItem name is Camera
Now i am working with camera fine
After taking my picture from camera i like to add some Note for that and save to my saved images and retrieving same image back and display in Gallery with Note wt i save
can any one say
how can i complete this App in good way
Code for save Images im using
mainpage.xaml.cs
private void saveimg_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
string fileName = myValue.ToShortDateString() + ".jpg";
var library = new MediaLibrary();
//library.SavePictureToCameraRoll(fileName, e.ChosenPhoto);
library.SavePicture(fileName, imageBits);
MessageBox.Show("Photo Saved to Picture Hub");
}
I need to Retrieve that that saved Image and display in my App when it loaded
If you need to access your image once it has been saved in the Media Library, you should also save it to the Isolated Storage.
Here is a tutorial that shows how to do that:
http://www.windowsphonegeek.com/tips/All-about-WP7-Isolated-Storage---Read-and-Save-Images
Save the image to Isolated Storage and Pictures Gallery. When wanting to see the image through the app, use image from Isolated Storage.
No need to use SQLite, use index numbers to save your image in Isolated storage, and also store comments with index numbers, that might ease you.

Why size of .mdb growing three times with small image?

I made few forms in Access 2010 and I add logo of company to the header form. This picture is .jpg and size of it is 70KB. I don't know why size of .mdb immediately increased from 4MB to 12MB? (few forms and the same logo) Maybe there is some options of image compression ?
Taken from http://office.microsoft.com/en-us/access-help/store-images-in-a-database-HP005280225.aspx
..."However, embedding images can rapidly inflate the size of your
database and cause it to run slowly. This is especially true if you
store GIF and JPEG files, because OLE creates additional bitmap files
that contain display information for each of your image files, and
those additional files can be larger than your original images. In
addition, this method only supports the Windows Bitmap (.bmp) and
Device Independent Bitmap (.dib) graphic file formats. If you want to
display other common types of image files, such as GIF and JPEG
images, you have to install additional software."...
To explain how these bitmap files are stored, the link below offers more explanation than the microsoft site:
Taken from http://www.ammara.com/support/kb/showkbe5cc.html
..."OLE Linking & Embedding is a technique used by Microsoft Access to
store 'Objects' in database tables.The technique relies on the
associated external application to store, present and edit the data.
In some cases an additional uncompressed 'preview' image is also saved
in the table (even when linking). This preview image is used for
faster display of the data, or when the server application isn't
available. This can cause a massive overhead. If you're storing jpeg
images the uncompressed preview can be ten or twenty times the actual
image size, causing the size of the database to rocket."...
So, when you drop an image onto a form in MS Access, uncompressed image data is saved to the system tables. This is actual uncompressed table data, so a compact and repair may offer little help.
The common workaround seems to be store the path to the image in a database table, and use that path to invoke the image on the form.
I don't know WHY (and I don't care) but I already noticed that behaviour as well. My workaround for company logos or equivalent is to insert it in ONE form, which I then insert as a subform wherever I need it. It has the added benefit that if the logo changes one day, there is only one place to update.

Image Wells, Core Data, and Sqlite files

I've got a mac application that I've developed.
I use it to create sqlite files that are bundled with my iphone app. The mac app uses Core Data and bindings and is working fine except for one "weird" issue.
I use an NSImageView (or Image Well) to allow me to drag and drop jpg files.
This is bound through to an optional binary attribute in my model class.
For some reason when I drag and drop a 4k jpg file it onto the image well and save the sqlite file. The data saved to the binary column is over 15 times larger than it should be.
Whereas if I use an application like SQLiteManager and add the image into the row in the database. The binary data is the correct (expected size).
File 4k jpg
Actual size: 2371.
Persisted via Core Data size: 35810.
Can anyone give me a suggestion as to why this might be happening?
Do I need to set some setting in Interface Builder or write some custom code?
Create dump from sqlite3 file and check which content use your space. I use plain sqlite3 to store image cache in Galileo and as far i know there db size ~ total images size.

Resources