ymahmood
Posts: 218
Score: 0
Joined: 8/13/2002
From: Birmingham - UK
Status: offline
|
Hi, I have images (jpgs) on the handheld, they are actually photo's. I am trying to show them in a picturebox. I have tried two different ways but both ways i am getting errors related to memory. The first method i tried was to to simply load the jpg as a bitmap and place into picturebox control ie pcbPhoto.Image = New Bitmap(pPhotoPath & lFieldVal) Doing it this way started to give me outofmemoryexception errors after displaying different images a number of times, i think i have understood why after reading up in this issue. So then I changed code to display the images using the OpennetCf way. What i did was create a function which returned a bitmap object which i then passed to the image property of the Picturebox control. here is that function: Function Bitmap_Return(ByVal lPath As String, ByVal lWidth As Integer, ByVal lHeight As Integer) As System.Drawing.Bitmap Dim lFactory As ImagingFactory = New ImagingFactoryClass() Dim lImg As IImage Dim lImgB As IBitmapImage Dim lErrPos As String = "" Try lFactory.CreateImageFromFile(lPath, lImg) lFactory.CreateBitmapFromImage(lImg, lWidth, lHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb, InterpolationHint.InterpolationHintDefault, lImgB) Bitmap_Return = ImageUtils.IBitmapImageToBitmap(lImgB) System.Runtime.InteropServices.Marshal.ReleaseComObject(lFactory) System.Runtime.InteropServices.Marshal.ReleaseComObject(lImg) System.Runtime.InteropServices.Marshal.ReleaseComObject(lImgB) GC.Collect() Catch ex As Exception MsgBox( " Err: " & ex.Message, MsgBoxStyle.Critical, "Bitmap_Return") End Try End Function I had to add the garbage collection because the file that i was opening was being locked by the OpennetCF, and GC released it. Any how, i am now getting another error, again the error does not happen all the time: "Not enough storage is available to complete this operation". When I get the error I check the memory status through settings and it seems fine. I cannot work out why apart from possibly a bug on OpennetCF side of things. I have rasied it with them but mean time need need a third way of displaying a photo in a picture box control, Any ideas ?? Thanks in advance.
|