bean_ian
asked on
Saving Large Photographs on WM6 CF2.0
Hi,
I have a small application that runs on a HTC Touch device. Basically it takes a picture and saves it to a sql server database via a webservice.
The device is running Windows Mobile 6 and the app i developed is running on compact framework 2.0.
The application works fine when using the Small,Medium or Large quality setting on the camera, however if I use the 1megapixel or 2megapixel setting I get a OutOfMemoryException after the picture is taken when i try load the freshly taken picture into a bitmap object.
Here is the memory spec for this device:
RAM
64 MB
ROM
128 MB
Any ideas how i can overcome this problem and save a 2mp picture? It is a requirement of the project that
the picture resolution is 2mp.
here is the code im using:
Dim fileName As String = String.Empty
Dim ccd As New CameraCaptureDialog
ccd.Mode = CameraCaptureMode.Still
ccd.StillQuality = CameraCaptureStillQuality. High
ccd.ShowDialog()
fileName = ccd.FileName
Show()
PictureBox1.Image = New Bitmap(fileName)'the exception occurs here
ccd.Dispose()
Cheers
IAn
I have a small application that runs on a HTC Touch device. Basically it takes a picture and saves it to a sql server database via a webservice.
The device is running Windows Mobile 6 and the app i developed is running on compact framework 2.0.
The application works fine when using the Small,Medium or Large quality setting on the camera, however if I use the 1megapixel or 2megapixel setting I get a OutOfMemoryException after the picture is taken when i try load the freshly taken picture into a bitmap object.
Here is the memory spec for this device:
RAM
64 MB
ROM
128 MB
Any ideas how i can overcome this problem and save a 2mp picture? It is a requirement of the project that
the picture resolution is 2mp.
here is the code im using:
Dim fileName As String = String.Empty
Dim ccd As New CameraCaptureDialog
ccd.Mode = CameraCaptureMode.Still
ccd.StillQuality = CameraCaptureStillQuality.
ccd.ShowDialog()
fileName = ccd.FileName
Show()
PictureBox1.Image = New Bitmap(fileName)'the exception occurs here
ccd.Dispose()
Cheers
IAn
ASKER
Yeah the user has to see the taken picture(in order to decide if it needs to be taken again). It is sent to the DB via a webservice(converted to a byte array then in the Webservice converted back to a bitmap). Doesnt even get that far though so that code is not an issue.
well, in order to investigate the possible solutions, I would check the memory usage, e.g. if PictureBox.Image is already allocated, how much memory is needed etc.
then I'd try something like this:
http://msdn2.microsoft.com/en-us/library/5ey6h79d.aspx
so the bottom line is to minimize memory usage on copying objects back and forth
then I'd try something like this:
http://msdn2.microsoft.com/en-us/library/5ey6h79d.aspx
so the bottom line is to minimize memory usage on copying objects back and forth
ASKER
I tried using lockbits to no avail. It makes no difference weather or not i load the image into PictureBox.Image or a brand new bitmap object, the same exception gets thrown
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks alexey. I used your idea and used OpenNetCf 2.1 imaging classes to create a thumbnail and display that and then write the large file directly to the DB.
Thanks for your help
Thanks for your help
ASKER
Here is the code for anyone who is interested:
Dim ccd As New CameraCaptureDialog
ccd.Mode = CameraCaptureMode.Still
ccd.StillQuality = CameraCaptureStillQuality. Default
ccd.ShowDialog()
fileName = ccd.FileName
Show()
' bmp = New Bitmap(fileName)
'bmpEx = New BitmapEx(ccd.FileName)
Dim oFile As System.IO.FileInfo
oFile = New System.IO.FileInfo(fileNam e)
Dim oFileStream As System.IO.FileStream = oFile.OpenRead()
ibitmap = OpenNETCF.Drawing.Imaging. ImageUtils .CreateThu mbnail(oFi leStream, New Drawing.Size(234, 181))
PictureBox1.Image = OpenNETCF.Drawing.Imaging. ImageUtils .IBitmapIm ageToBitma p(ibitmap)
ccd.Dispose()
Dim ccd As New CameraCaptureDialog
ccd.Mode = CameraCaptureMode.Still
ccd.StillQuality = CameraCaptureStillQuality.
ccd.ShowDialog()
fileName = ccd.FileName
Show()
' bmp = New Bitmap(fileName)
'bmpEx = New BitmapEx(ccd.FileName)
Dim oFile As System.IO.FileInfo
oFile = New System.IO.FileInfo(fileNam
Dim oFileStream As System.IO.FileStream = oFile.OpenRead()
ibitmap = OpenNETCF.Drawing.Imaging.
PictureBox1.Image = OpenNETCF.Drawing.Imaging.
ccd.Dispose()
is it a must to display newly taken picture? and how do you send it to remote database? maybe it is possible in your design just to read binary data from the file and send it over?
BR,
Alex