Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

Out of Memory when loading a photo

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-22-2008, 04:10 PM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 295
Awards Showcase
Beta Tester 
Total Awards: 1
Default Out of Memory when loading a photo

Hi all,

I was looking for a small quick image viewer, one that can be linked to image files (open on double click)
I couldn't find anything I liked so I tried something myself

I have 2 files 1 landscape and 1 portrait.

This is the sub, but when I call it the ide (on the ppc) gives me an Out Of Memory error, this only happens with an image file of 737KB the 593KB file loads as it should...

Code:
Sub ProcessImage(Image)
Image = 
"L.jpg"
    Img.New1(AppPath&
"\"&Image)
    
If Img.Width > Img.Height Then 
        
'Landscape
        AddImage("Form1","Image",20,75,200,150)
    
Else If Img.Width < Img.Height Then     
        
'Portait
        AddImage("Form1","Image",45,40,150,200)
    
End If 
Control(
"Image").Image = Img.Value
Control(
"Image").Mode = cStretchImage 

End Sub
Is there a better way to accomplish this, or is there a memory estriction on B4P ...
Am i missing something

in other words


Please?
Reply With Quote
  #2 (permalink)  
Old 10-22-2008, 04:36 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Mr_Gee View Post
is there a memory restriction on B4P ...
That 737K jpg is going to expand to about 10 megabytes of bitmap data or more, the exact amount depending upon how compressed it is so you may well be genuinely running out of memory on the device!
Reply With Quote
  #3 (permalink)  
Old 10-22-2008, 09:20 PM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 295
Awards Showcase
Beta Tester 
Total Awards: 1
Default

@#$%

So B4P is decompressing the jpg into a bmp...
kinda like a temp file...

How would I go about fixing this ?
there are picture viewers out there which are create using .net
so it must be possible...
Reply With Quote
  #4 (permalink)  
Old 10-23-2008, 08:55 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Mr_Gee View Post
How would I go about fixing this ?
If you want to display pictures that big your only option is to free up memory.


Quote:
there are picture viewers out there which are create using .net
so it must be possible...
It is not a .NET thing, run the program on yout PC and it will be fine. It is a shortage of memory - big pictures need lots of memory. I'm afraid its governed by the laws of nature.
Reply With Quote
  #5 (permalink)  
Old 10-23-2008, 10:26 AM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 295
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by agraham View Post
If you want to display pictures that big your only option is to free up memory.
It is not a .NET thing, run the program on yout PC and it will be fine. It is a shortage of memory - big pictures need lots of memory. I'm afraid its governed by the laws of nature.
Isn't there a way around this?
I mean, there are plenty applications that display pictures, and that don't have this issue
B4P creates a bmp file, but isn't there any way that it uses the existing jpg file?
this should also help loading times (since it doesn't need to decompress)
Reply With Quote
  #6 (permalink)  
Old 10-23-2008, 11:09 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Mr_Gee View Post
B4P creates a bmp file, but isn't there any way that it uses the existing jpg file?
this should also help loading times (since it doesn't need to decompress)
Please don't take offence but I think we have a lack of understanding of what's going on here.

The way that an image is represented for manipulation or display is as a bitmap where each pixel is represented by one or more bytes of data. Devices running .NET 2.0 can support bitmaps using 2, 3 or 4 bytes per pixel. For 2 bytes per pixel 5 bits are used to represent each colour with green possibly using the sixth bit. 3 bytes per pixel give red, green and blue values of 8 bits each and 4 bytes adds a transparency value as the fourth byte. All images, no matter what their storage format, must be decoded into one of these formats before display. The default on the device, according to the Microsofts docs though I haven't confirmed this myself, is 4 bytes per pixel and the default is what ImageLib (and ImageLibEx) uses.

The picture data from a bitmap can be stored in a file in one of several formats that compress the bitmap data, either reversibly or in a lossy manner. However in all cases the data must be decompressed before use. You cannot use jpg file data as it stands - it must be decoded into a bitmap. If you start at "Bitmap" in Wikipedia there are links to the file storage formats you can explore.
Reply With Quote
  #7 (permalink)  
Old 10-23-2008, 07:49 PM
Basic4ppc Veteran
 
Join Date: Feb 2008
Location: Hilversum, The Netherlands
Posts: 295
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by agraham View Post
Please don't take offense but I think we have a lack of understanding of what's going on here.
No I don't feel offended, I'm happy someone know what he is talking about
B4P is a great tool, and I can get things done, but there is still soo much more to learn

I'm glad you are not offended by some of my n00b questions :-)
so thanks again
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Photo Picker? Offbeatmammal Questions (Windows Mobile) 0 06-02-2008 04:16 AM
Photo display program with smooth control Frank Share Your Creations 3 01-14-2008 02:56 PM
How much memory remains? willisgt Questions (Windows Mobile) 1 12-05-2007 07:55 AM
Memory Usage Scubaticus Questions (Windows Mobile) 6 07-03-2007 05:37 PM
Out of Memory error while loading bitmap HARRY Questions (Windows Mobile) 3 05-15-2007 12:12 PM


All times are GMT. The time now is 02:54 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0