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

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Code Samples & Tips > Additional Libraries
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Additional Libraries Users contributed libraries.
This sub-forum is only available to licensed users.

ImageLibEx library

Reply
 
LinkBack Thread Tools Display Modes
  #101 (permalink)  
Old 04-06-2009, 06:01 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

On my Sony Vaio labtop with NVIDIA GeForce Go 7400 graphic card,
with XP SP3 and color depth set to 32 bits it works OK.

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #102 (permalink)  
Old 04-06-2009, 06:19 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Looks like it may be a chipset/driver issue. My EEE PC and Laptop are both XP SP3 but both use an Intel graphics chip and driver and both work at 16bit but not 32 bit color depth.
Reply With Quote
  #103 (permalink)  
Old 11-08-2009, 05:21 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Version 1.6 now posted with a single change.

I tried to use dzImage screen capture on the device but it wouldn't work for me so I have added a ScreenCapture method to BitmapEx.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #104 (permalink)  
Old 11-10-2009, 04:10 AM
Knows the basics
 
Join Date: Dec 2008
Posts: 77
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Good job on the ScreenShot, nice and simple.
Reply With Quote
  #105 (permalink)  
Old 11-15-2009, 05:53 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Version 1.7 posted.

Added to DrawerEx are Draw/FillArc and Draw/FillPie methods. The "1" methods draw circles, the "2" methods draw ellipses. Although you can draw circles with the ellipse methods they are more processor intensive as they deal with two axes whereas the the circle methods do less processing as they only deal with a radius. The demo has an extra page added to show these.

Unlike the other DrawerEx methods these new methods are not native but are coded within ImagelibEx and use Draw/FillLines and Draw/FillPolygon to draw so there may be a performance penalty when using them compared to using the native methods.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #106 (permalink)  
Old 11-17-2009, 11:04 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Version 1.8 posted with some significant improvements.

The Draw/FillArc and Draw/FillPie methods added in version 7 have their zero points moved to 12 o'clock (from 3 o'clock - a bad previous decision ) to match a compass.

DrawLineDashed and DrawLineDashDot methods are added to DrawerEx to enabled various patterns of line to be drawn.

GcCollect and GetTotalMemory are added to BitmapEx. These are intended for possible diagnostic use and should not be required in normal use.

A Locked property, and LockBits, GetLockedPixel, SetLockedPixel and UnlockBits methods are added to BitmapEx to provide fast low level access to bitmap pixel data if required.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #107 (permalink)  
Old 11-17-2009, 12:15 PM
Basic4ppc Veteran
 
Join Date: Jul 2008
Location: Borchen, Germany
Posts: 434
Send a message via ICQ to corwin42
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by agraham View Post
GcCollect and GetTotalMemory are added to BitmapEx. These are intended for possible diagnostic use and should not be required in normal use.
As you mention this I have a question about memory handling and BitMapEx objects.

I'm currently writing an OpenStreetMap Mapviewer program for the device. OpenStreetMap Maps are generated from tiles with 256x256 pixels. For displaying the complete map I have to load several tiles and put them on an image. In the first version this was done with two BitMapEx objects. One for the tile (bmpTile) and another (bigger) for the map (bmpImage) which will be displayed.

The tiles were loaded with bmpTile.New1(filename) and then copied to the correct position on bmpImage with a DrawerEx Object with drwImage.DrawImage(bmpTile.Value, ...).

The problem with this solution was that when scrolling around, many tiles are loaded with bmpTile.New1() method and I get an OutOfMemory exception very soon.

I looked into the source of ImageLibEx and I don't understand why I get the OutOfMemory Exception because when the New1() Method is called the old bitmap gets disposed and a new one is created.

Is the GarbageCollector too slow in freeing the not used memory or is there somewhere a memory leak?

Currently I use a ControlsExDevice/NativeImage for Loading the tiles with nImgTile.LoadPicture(filename). This works well and I have no OutOfMemory exceptions any more.

As a conclusion BitMapEx.New1() method called several times on the same objects seems to eat up memory but I don't understand why. Perhaps I should try it again with calling GcCollect after calling bmpTile.New1() method.

Greetings,
Markus
Reply With Quote
  #108 (permalink)  
Old 11-17-2009, 12:53 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by corwin42 View Post
I looked into the source of ImageLibEx and I don't understand why I get the OutOfMemory Exception because when the New1() Method is called the old bitmap gets disposed and a new one is created.
Ah, I had forgotten that was there! That Dispose in New1 actually does nothing! but is harmless. It is a result of my early misunderstanding of what Basic4ppc does when it sees a New method and I should have removed it a long time ago.

Code:
BmpEx1.New1(filename) ' creates a new instance of a BitmapEx and calls New1
....
BmpEx1.New1(filename)
' creates another new instance of a BitmapEx and calls New1
The first BmpEx is left floating and unreferenced and should be swept up by the GC. The second BmpEx1 is a totally new instance and so has no reference to the original bitmap that was in the first BmpEx instance so the Dispose test is unnecessary.

Most of the memory in a Bitmap is unmanaged memory which the GC knows nothing about so successive calls to New1 to the same object build up a list of floating Bitmaps but as the managed memory overhead of a Bitmap is small the GC may not run before unmanaged memory runs out. Explicitly Disposing and recreating the BitmapEx object should overcome this problem.

Code:
BmpEx1.New1(filename) 
....
BmpEx1.Dispose
AddObject(
"BmpEx""BitmapEx")
BmpEx1.New1(filename)
' creates another new instance of a BitmapEx and calls New1
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #109 (permalink)  
Old 11-17-2009, 02:43 PM
Basic4ppc Veteran
 
Join Date: Jul 2008
Location: Borchen, Germany
Posts: 434
Send a message via ICQ to corwin42
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Thanks very much for your explanation.

I have found some articles about this now in the internet and when I understand it correct, I should call Dispose() on objects which implement IDisposable when I don't need them any more.

I often call New() methods on objects to reinitialize them without disposing them first. Am I right that this is normally not a problem (because the GC will handle this) but it's a bad idea for objects that use unmanaged memory or implement IDisposable?

Thanks,
Markus
Reply With Quote
  #110 (permalink)  
Old 11-17-2009, 02:59 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by corwin42 View Post
Am I right that this is normally not a problem (because the GC will handle this)
Yes, normally you should let the GC do its' job.
Quote:
but it's a bad idea for objects that use unmanaged memory or implement IDisposable?
It's only really a problem for things like (and it's the only example I can think of) Bitmaps where the ratio of unmanaged memory used by the underlying native object is very large in relation to the small amount of managed memory used to encapsulate it for .NET use. Before reusing the same object name the only things other than Bitmap and BitmapEx that I would rooutinely Dispose would be Drawer andDrawerEx that are really GDI Graphics objects.

If you don't have problems I would not worry about memory use or using Dispose.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
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
Door library (Beta) - Special library Erel Official Updates 60 01-13-2011 12:23 PM
Merging Outlook library and Phone library Erel Official Updates 11 09-15-2010 10:22 AM
PhoneticAlgorithms Library (ex-StringComparison Library) moster67 Additional Libraries 10 11-11-2008 08:46 PM
ImageLibEx? agraham Basic4ppc Wishlist 2 11-05-2007 02:15 PM
ImageLibeX Error XerVision Questions (Windows Mobile) 8 08-27-2007 07:14 PM


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


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