Thread: [Fremantle Maemo5] [Announce] Advanced Geocaching Tool
View Single Post
Posts: 35 | Thanked: 27 times | Joined on Jun 2008 @ Finland
#300
New AGTL seems to be working nicely, thanks!

I still needed to add in the power optimizations though (peterleinchen's method for the screen off detection works nice) to get the background cpu usage down to good levels.

I also wanted to have JPEG satellite image maps support, but only PNG images are currently supported. It turned out it was quite easy to add jpeg support, I did the following to _load_tile in gtkmap.py:

Code:
    @staticmethod
    def _load_tile(filename):
        try:
          surface = cairo.ImageSurface.create_from_png(filename)
        except MemoryError:
          # Try JPEG. Load jpeg image, add alpha channel (32 bits), create imagesurface
          pixbuf24 = gtk.gdk.pixbuf_new_from_file(filename)
          pixbuf = pixbuf24.add_alpha(False, chr(0), chr(0), chr(0))
          pix_data = pixbuf.get_pixels_array()
          surface = cairo.ImageSurface.create_for_data(pix_data, cairo.FORMAT_RGB24, pixbuf.get_width(), pixbuf.get_height(), pixbuf.get_rowstride())
        if surface.get_width() != surface.get_height():
            raise Exception("Image too small, probably corrupted file")
        return surface
Would be more ideal to detect the image format somehow instead of using the exception, but this works ok. The maps source I am using even has ".png" in the url, but when zooming in close enough it turns into a jpeg satellite image. (it is quite nice though )
 

The Following User Says Thank You to Kegetys For This Useful Post: