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.

image zoom memory problem

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-06-2009, 07:13 PM
Junior Member
 
Join Date: May 2007
Location: Germany
Posts: 45
Question image zoom memory problem

b4PPC V 6.5 optimized compilation

I am working on an app to view files related to OziExplorerCE

http://www.basic4ppc.com/forum/share...es-viewer.html

Zooming with ImageLibEx.dll is still not really clear to me.

@Klaus:
In your scaledMap project
http://www.basic4ppc.com/forum/chit-...3-mapping.html
for zooming you use the dzImage DLL instead of mapDisplay.Zoom(zoom.Value) from ImageLibEx.

Is that because the increasing memory consumption with every zoom action?
That is what happens with my FS Loox 720 Win 2003 SE. and as well on the desktop.

So for zooming I use dzImage as well.
But with it I have also problems.
The jpg map inflatet to bitmap is about 1.3 MByte.
With a zoom of 160 % I get a "OutOfMemoryException"

With a zoom of 100 % i have 22 MB of free memory.
With a zoom of 120 % i have 21.6 MB of free memory.
With a zoom of 140 % i have 20.9 MB of free memory.
With a zoom of "160 %" (which didn't zoom) i have 20.9 MB of free memory as well after the error message.

The same image viewed and zoomed with other apps as "TCPMP" or "Album für Pocket PC" is no problem at all.

With this apps a zoom doesn't even change the use of memory.
As well they don't keep a copy of the original image for zooming.
(if I load the image with my app memory decreases by ~2.6 MB.
with these other apps by ~1.3 MB) (the used image is included in the above project:"Ozi Files Viewer")


Are there different strategies with zooming?
Am I doing something wrong?
and does anybody know a way for me to achieve higher zoom levels without needing an other image file?


ZPktX is the zoom point (middle of screen)
Code:
mapDisplay.New3(il1.Item(0))
drwDisplay.New2(mapDisplay.Value)     
' DrawerEx drawer object to draw onto the map image
drwMap.New1("frmMap",False)       ' drawer object to draw the part of the map image onto the form
BiExZoom.New3(mapDisplay.Value) ' BitmapEx copy for zooming
frmMap.Refresh

.
.
.

'zoom:
mapDisplay.Value=dzImage.ZoomImage(BiExZoom.Value,numZoom.Value)  
rectSrc.x = -(ZPktX -ZPktX *numZoom.Value/
100)  ' keep centering on the zoom point
rectSrc.y = -(ZPktY -ZPktY *numZoom.Value/100 )
drwMap.DrawImage(mapDisplay.Value,rectSrc.Value,rectDest.Value,
False)
frmMap.Refresh


Thanks a lot for any hints

Bernd
Reply With Quote
  #2 (permalink)  
Old 01-06-2009, 09:22 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi BerndB,

I have also the Out of memory problem with bigger zoom factors on the device, but have not yet looked at it in detail. Will be done quite soon.

I use the dzImage library because I had already used it in my first Map programm. And I didn't remember that the ImageLibEx has alson a Zoom function. I remembered having seen it once, but didn't find it in the help file of the ImageLibEx library, so I used what I knew.

I have now entered the Zoom function of the ImageLibEx library in the ScaledMap programm.

Using the dzImage library or the ImageLibEx library will have no difference from the memory point of view, both generate a bigger bitmap and nothing else.

One question about your code:
What image do you have in il1.Item(0) ?
Code:
mapDisplay.New3(il1.Item(0))
If it is the original image you don't need this extra bitmap
Code:
BiExZoom.New3(mapDisplay.Value) ' BitmapEx copy for zooming
you can directly use:
Code:
mapDisplay.Value=dzImage.ZoomImage(il1.Item(0),numZoom.Value)
instead of
Code:
mapDisplay.Value=dzImage.ZoomImage(BiExZoom.Value,numZoom.Value)
This saves you 1 image !

As soon as I have some other news I will post it here.

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #3 (permalink)  
Old 01-06-2009, 11:54 PM
Junior Member
 
Join Date: May 2007
Location: Germany
Posts: 45
Default

Hi Klaus,

thanks for your quick response.

The code snippet is a bit simplified.
in il1.Item(0) is the original image.

but before zooming there are drawn Circles onto the image.
So image + circles are in BiExZoom.New3 to be zoomed.


Concerning memory with dzImage or ImageLibEx I found a funny thing:

In scaledMap as well as in OziFilesView I alternatively used the two zoom methods.
At first dzImage was active. (The left part of each Thumbnail.)
I quickly clicked 5 zoom steps up and then 5 zoom steps down.
This I repeated several times.

scaledMap:
Code:
Sub Zoom(Fact)
    ZoomFact=ZoomFact*Fact

    bmpDisplay.New3(IL3.Item(
0))      ' ImageLibEx 
    bmpDisplay.Zoom(ZoomFact*100)
    
'bmpDisplay.Value=dzImage.ZoomImage(IL3.Item(0),ZoomFact*100) 'dzImage
    
       InitMap
    DrawElements
End Sub
(by the way: in DrawElements is done zooming as well)


OziFilesView:
Code:
Sub numZoom_ValueChanged
    mapDisplay.New3(BiExZoom.Value)
        mapDisplay.Zoom(numZoom.Value) 
    
'mapDisplay.Value= dzImage.ZoomImage(BiExZoom.Value,numZoom.Value)  
       
        rectSrc.x = -(ZPktX -ZPktX *numZoom.Value/
100)  ' keep centering on the zoom point
        rectSrc.y = -(ZPktY -ZPktY *numZoom.Value/100 )

    drwMap.DrawImage(mapDisplay.Value,rectSrc.Value,rectDest.Value,
False)
       frmMap.Refresh
        
End Sub
This was done on the desktop

The thumbnails are taken from the XP-taskmanager.

Using ImageLibEx you can see a increasing of used memory in both apps.

Using dzImage with OziFilesView shows increasing while zoom in
and decreasing while zoom out.
With scaledMap it shows continued increasing again.

funny, but no idea at present

cheers
Bernd
Reply With Quote
  #4 (permalink)  
Old 01-07-2009, 09:04 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

Try the new version 1.4 of ImageLibEx that I have just posted. It has a one line change in BitmapEx.Zoom to dispose the old pre-zoom butmap object which I missed including. All the other methods that generate a new Bitmap do it but I missed it on the Zoom method. I don't know whether it will make a difference as the .NET garbage collector might have picked it up anyway but it is worth trying.
Reply With Quote
  #5 (permalink)  
Old 01-07-2009, 10:05 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi Andrew,

Thank's for the update.

One question,
After the creation with BitmapEx1.New3(IL1.Item(0)) ,
what is the best practice to assign a new image to a BitmapEx ?
Using
BitmapEx1.Value=IL1.Item(0) or
BitmapEx1.New3(IL1.Item(0))

Thank you in advance for your answer and Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #6 (permalink)  
Old 01-07-2009, 10:20 AM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Hi BerndB,

The zooming in the DrawElements routine is necessary because when I redraw the graphic elements I need to assign a new image to the form without any drawings on it and as I memorize only the original image and not the zoomed image I must zoom it before assigning it to the form.
The DrawElements routine is in fact a Redraw routine also used when I delete drawing elements and not only after zooming.

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #7 (permalink)  
Old 01-07-2009, 11:39 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 klaus View Post
what is the best practice to assign a new image to a BitmapEx ?
The answer is - it depends!

BitmapEx1.New3 - disposes of any old Bitmap and saves a reference to the new. This is best if the old Bitmap is not in use anywhere

BitmapEx1.Value - just saves a reference to the new Bitmap. This is best if the old Bitmap is in use anywhere (like in an Image control) as disposing of it is probably not you want as the Bitmap might disappear if only a reference to the Bitmap was assigned when it was "used" rather than the contents being copied to another Bitmap.

If in doubt I would use New3 and see if any images vanish unexpectedly.
Reply With Quote
  #8 (permalink)  
Old 01-07-2009, 12:17 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Thank you for the explanations.
It has become more clear to me now.

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #9 (permalink)  
Old 01-07-2009, 09:25 PM
Junior Member
 
Join Date: May 2007
Location: Germany
Posts: 45
Default

Hi Andrew,

thank you for the new version of ImageLibEx.

For the memory behavior I am sorry to say that nothing has changed.
Still with every zoom action regardless of zooming in or out, free memory is shrinking.
and still the OutOfMemoryException is coming very soon.

regards
Bernd
Reply With Quote
  #10 (permalink)  
Old 01-08-2009, 08:13 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

Can you post a test app that shows this behaviour and I will see if I can find where the memory is going?

Do you get "Out of memory" with both dzImage and ImageLibEx?

Last edited by agraham : 01-08-2009 at 08:15 AM.
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
SQl retrieve image problem Cableguy Questions (Windows Mobile) 2 11-12-2008 02:30 PM
MouseMove over Image - problem DaveW Questions (Windows Mobile) 10 11-04-2008 08:27 AM
Image problem with ImageButtons klaus Bug Reports 3 02-15-2008 08:10 AM
Font properties & Zoom Nycran Basic4ppc Wishlist 0 11-11-2007 11:23 AM
Zoom ! Pete_engineer Basic4ppc Wishlist 7 09-15-2007 10:59 PM


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


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