added bitmap support for gif,tiff,jpg,jpeg,bmp,png
parent
0d009ac52b
commit
3b901d9775
|
@ -20,7 +20,7 @@ import zipfile
|
||||||
import tempfile
|
import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
import svg.document as wxpsvgdocument
|
import svg.document as wxpsvgdocument
|
||||||
|
import imghdr
|
||||||
|
|
||||||
class dispframe(wx.Frame):
|
class dispframe(wx.Frame):
|
||||||
def __init__(self, parent, title, res=(800, 600), printer=None):
|
def __init__(self, parent, title, res=(800, 600), printer=None):
|
||||||
|
@ -62,7 +62,7 @@ class dispframe(wx.Frame):
|
||||||
gc.Translate(*self.offset)
|
gc.Translate(*self.offset)
|
||||||
gc.Scale(self.scale, self.scale)
|
gc.Scale(self.scale, self.scale)
|
||||||
wxpsvgdocument.SVGDocument(image).render(gc)
|
wxpsvgdocument.SVGDocument(image).render(gc)
|
||||||
elif self.slicer == 'bmp':
|
elif self.slicer == 'bitmap':
|
||||||
dc.DrawBitmap(image, self.offset[0], -self.offset[1], True)
|
dc.DrawBitmap(image, self.offset[0], -self.offset[1], True)
|
||||||
else:
|
else:
|
||||||
raise Exception(self.slicer + " is an unknown method.")
|
raise Exception(self.slicer + " is an unknown method.")
|
||||||
|
@ -108,7 +108,7 @@ class dispframe(wx.Frame):
|
||||||
self.scale = scale
|
self.scale = scale
|
||||||
self.thickness = thickness
|
self.thickness = thickness
|
||||||
self.index = 0
|
self.index = 0
|
||||||
self.size = (size[0]+offset[0],size[1]+offset[1])
|
self.size = (size[0] + offset[0], size[1] + offset[1])
|
||||||
self.interval = interval
|
self.interval = interval
|
||||||
self.offset = offset
|
self.offset = offset
|
||||||
self.timer = wx.Timer(self, 1)
|
self.timer = wx.Timer(self, 1)
|
||||||
|
@ -202,15 +202,16 @@ class setframe(wx.Frame):
|
||||||
def parse3DLPzip(self, name):
|
def parse3DLPzip(self, name):
|
||||||
if not zipfile.is_zipfile(name):
|
if not zipfile.is_zipfile(name):
|
||||||
raise Exception(name + " is not a zip file!")
|
raise Exception(name + " is not a zip file!")
|
||||||
|
acceptedImageTypes = ['gif','tiff','jpg','jpeg','bmp','png']
|
||||||
zipFile = zipfile.ZipFile(name, 'r')
|
zipFile = zipfile.ZipFile(name, 'r')
|
||||||
self.image_dir = tempfile.mkdtemp()
|
self.image_dir = tempfile.mkdtemp()
|
||||||
zipFile.extractall(self.image_dir)
|
zipFile.extractall(self.image_dir)
|
||||||
ol = []
|
ol = []
|
||||||
for f in os.listdir(self.image_dir):
|
for f in os.listdir(self.image_dir):
|
||||||
path = os.path.join(self.image_dir, f)
|
path = os.path.join(self.image_dir, f)
|
||||||
if os.path.isfile(path) and path.endswith(".bmp"):
|
if os.path.isfile(path) and imghdr.what(path) in acceptedImageTypes:
|
||||||
ol.append(wx.Bitmap(path))
|
ol.append(wx.Bitmap(path))
|
||||||
return ol, -1, "bmp"
|
return ol, -1, "bitmap"
|
||||||
|
|
||||||
def loadfile(self, event):
|
def loadfile(self, event):
|
||||||
dlg = wx.FileDialog(self, ("Open file to print"), style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
|
dlg = wx.FileDialog(self, ("Open file to print"), style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
|
||||||
|
|
Loading…
Reference in New Issue