[GRASS-SVN] r35428 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jan 16 00:23:44 EST 2009
Author: cmbarton
Date: 2009-01-16 00:23:44 -0500 (Fri, 16 Jan 2009)
New Revision: 35428
Modified:
grass/trunk/gui/wxpython/gui_modules/mapdisp.py
grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
Log:
Fixed bug that prevented saving in formats other than png. Also added other graphic handlers to allow saving in additional formats.
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2009-01-16 05:18:34 UTC (rev 35427)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp.py 2009-01-16 05:23:44 UTC (rev 35428)
@@ -860,30 +860,51 @@
"""
Save image to file
"""
- filetype = "PNG file (*.png)|*.png|"\
+ filetype = "BMP file (*.bmp)|*.bmp|"\
+ "GIF file (*.gif)|*.gif|"\
+ "JPG file (*.jpg)|*.jpg|"\
+ "PCX file (*.pcx)|*.pcx|"\
+ "PNG file (*.png)|*.png|"\
+ "PNM file (*.pnm)|*.pnm|"\
"TIF file (*.tif)|*.tif|"\
- "GIF file (*.gif)|*.gif"
+ "XPM file (*.xpm)|*.xpm"
- dlg = wx.FileDialog(self, "Choose a file name to save the image as a PNG to",
+ dlg = wx.FileDialog(self, "Choose a file name to save the image (no need to add extension)",
defaultDir = "",
defaultFile = "",
wildcard = filetype,
style=wx.SAVE|wx.FD_OVERWRITE_PROMPT)
if dlg.ShowModal() == wx.ID_OK:
+ path = dlg.GetPath()
+ if path == None: return
base = os.path.splitext(dlg.GetPath())[0]
ext = os.path.splitext(dlg.GetPath())[1]
if dlg.GetFilterIndex() == 0:
+ type = wx.BITMAP_TYPE_BMP
+ if ext != '.bmp': path = base+'.bmp'
+ if dlg.GetFilterIndex() == 1:
+ type = wx.BITMAP_TYPE_GIF
+ if ext != '.gif': path = base+'.gif'
+ elif dlg.GetFilterIndex() == 2:
+ type = wx.BITMAP_TYPE_JPEG
+ if ext != '.jpg': path = base+'.jpg'
+ elif dlg.GetFilterIndex() == 3:
+ type = wx.BITMAP_TYPE_GIF
+ if ext != '.pcx': path = base+'.pcx'
+ elif dlg.GetFilterIndex() == 4:
type = wx.BITMAP_TYPE_PNG
- path = dlg.GetPath()
if ext != '.png': path = base+'.png'
- elif dlg.GetFilterIndex() == 1:
+ elif dlg.GetFilterIndex() == 5:
+ type = wx.BITMAP_TYPE_PNM
+ if ext != '.pnm': path = base+'.pnm'
+ elif dlg.GetFilterIndex() == 6:
type = wx.BITMAP_TYPE_TIF
if ext != '.tif': path = base+'.tif'
- elif dlg.GetFilterIndex() == 2:
- type = wx.BITMAP_TYPE_TIF
- if ext != '.gif': path = base+'.gif'
+ elif dlg.GetFilterIndex() == 7:
+ type = wx.BITMAP_TYPE_XPM
+ if ext != '.xpm': path = base+'.xpm'
self.MapWindow.SaveToFile(path, type)
-
+
dlg.Destroy()
def PrintMenu(self, event):
Modified: grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2009-01-16 05:18:34 UTC (rev 35427)
+++ grass/trunk/gui/wxpython/gui_modules/mapdisp_window.py 2009-01-16 05:23:44 UTC (rev 35428)
@@ -481,6 +481,13 @@
# get the image to be rendered
self.img = self.GetImage()
+ if self.img != None:
+ self.img.AddHandler(JPEGHandler)
+ self.img.AddHandler(GIFHandler)
+ self.img.AddHandler(BMPHandler)
+ self.img.AddHandler(XPMHandler)
+ self.img.AddHandler(PNMHandler)
+ self.img.AddHandler(PCXHandler)
# update map display
if self.img and self.Map.width + self.Map.height > 0: # scale image during resize
More information about the grass-commit
mailing list