示例#1
0
 def create(self):
     family = ConstantTable.getEnum('fontfamily', self.family)
     style = ConstantTable.getEnum('fontstyle', self.style)
     weight = ConstantTable.getEnum('fontweight', self.weight)
     font = wx.Font(self.size, family, style, weight, self.underlined,
                    self.faceName)
     self.font = self.renderer.wx_renderer.CreateFont(font, self.colour)
示例#2
0
    def create(self):
        if self.wx_pen is not None:
            pen = self.wx_pen
        else:
            pen = wx.Pen(self.colour, self.width, ConstantTable.getValue(self.style))

        pen.SetCap(ConstantTable.getEnum("cap", self.cap))
        pen.SetJoin(ConstantTable.getEnum("join", self.join))
        if self.dashes is not None:
            pen.SetDashes(self.dashes)
        if self.stipple is not None:
            pen.SetStipple(self.stipple)

        self.pen = self.renderer.wx_renderer.CreatePen(pen)
示例#3
0
    def create(self):
        if self.wx_pen is not None:
            pen = self.wx_pen
        else:
            pen = wx.Pen(self.colour, self.width,
                         ConstantTable.getValue(self.style))

        pen.SetCap(ConstantTable.getEnum('cap', self.cap))
        pen.SetJoin(ConstantTable.getEnum('join', self.join))
        if self.dashes is not None:
            pen.SetDashes(self.dashes)
        if self.stipple is not None:
            pen.SetStipple(self.stipple)

        self.pen = self.renderer.wx_renderer.CreatePen(pen)
示例#4
0
    def getData(self, file_format):
        ''' Returns the picture of this surface as a string with file_format.
            where file format can be something like 'png', 'jpg' or 'raw' or any
            other kind of supported image format.
        '''
        if file_format == 'raw':
            # bit faster than the raw2 method because we use array.array.
            #  Should probably use a numpy array instead.
            noPixels = self.bitmap.Size[0] * self.bitmap.Size[1]
            if self.hasAlpha:
                result = array.array('c', '\0' * 4 * noPixels)
                self.bitmap.CopyToBuffer(result, wx.BitmapBufferFormat_RGBA)
                #self.bitmap.CopyToBuffer( result, wx.BitmapBufferFormat_ARGB32 )
                return result.tostring()
            else:
                result = array.array('c', '\0' * 3 * noPixels)
                self.bitmap.CopyToBuffer(result, wx.BitmapBufferFormat_RGB)
                return result.tostring()
        elif file_format == 'raw2':
            # very slow, because we iterate over each pixel
            result = ''
            for it in wx.AlphaPixelData(self.bitmap):
                pixel = it.Get()
                result += chr(pixel[0]) + chr(pixel[1]) + chr(pixel[2])
                if self.bitmap.HasAlpha():
                    result += chr(pixel[3])
            return result

        else:
            img = self.bitmap.ConvertToImage()

            import cStringIO
            outputStream = cStringIO.StringIO()
            if file_format == 'jpg':
                file_format = 'jpeg'
            img.SaveStream(wx.OutputStream(outputStream),
                           ConstantTable.getEnum('bitmap_type', file_format))
            data = outputStream.getvalue()
            outputStream.close()

            return data
示例#5
0
    def getData(self, file_format):
        ''' Returns the picture of this surface as a string with file_format.
            where file format can be something like 'png', 'jpg' or 'raw' or any
            other kind of supported image format.
        '''
        if file_format == 'raw':
            # bit faster than the raw2 method because we use array.array.
            #  Should probably use a numpy array instead.
            noPixels = self.bitmap.Size[0] * self.bitmap.Size[1]
            if self.hasAlpha:
                result = array.array( 'c', '\0' * 4 * noPixels )
                self.bitmap.CopyToBuffer( result, wx.BitmapBufferFormat_RGBA )
                #self.bitmap.CopyToBuffer( result, wx.BitmapBufferFormat_ARGB32 )
                return result.tostring()
            else:
                result = array.array( 'c', '\0' * 3 * noPixels )
                self.bitmap.CopyToBuffer( result, wx.BitmapBufferFormat_RGB )
                return result.tostring()
        elif file_format == 'raw2':
            # very slow, because we iterate over each pixel
            result = ''
            for it in wx.AlphaPixelData(self.bitmap):
                pixel = it.Get()
                result += chr(pixel[0]) + chr(pixel[1]) + chr(pixel[2])
                if self.bitmap.HasAlpha():
                    result += chr(pixel[3])
            return result

        else:        
            img = self.bitmap.ConvertToImage()        
            
            import cStringIO
            outputStream = cStringIO.StringIO()
            if file_format == 'jpg':
                file_format = 'jpeg'
            img.SaveStream( wx.OutputStream(outputStream), ConstantTable.getEnum( 'bitmap_type', file_format ) )
            data = outputStream.getvalue()
            outputStream.close()
                  
            return data
示例#6
0
 def create(self):
     family = ConstantTable.getEnum("fontfamily", self.family)
     style = ConstantTable.getEnum("fontstyle", self.style)
     weight = ConstantTable.getEnum("fontweight", self.weight)
     font = wx.Font(self.size, family, style, weight, self.underlined, self.faceName)
     self.font = self.renderer.wx_renderer.CreateFont(font, self.colour)
示例#7
0
 def Fill(self, fillStyle="oddeven"):
     return self.renderer.GC.FillPath(self.path, ConstantTable.get(fillStyle))
示例#8
0
 def FillAndStroke(self, fillStyle="oddeven"):
     return self.renderer.GC.DrawPath(self.path, ConstantTable.get(fillStyle))
示例#9
0
 def DrawLines(self, points, fillStyle='oddeven'):
     return self.GC.DrawLines(points, ConstantTable.get(fillStyle))
示例#10
0
 def Fill(self, fillStyle='oddeven'):
     return self.renderer.GC.FillPath(self.path,
                                      ConstantTable.get(fillStyle))
示例#11
0
 def FillAndStroke(self, fillStyle='oddeven'):
     return self.renderer.GC.DrawPath(self.path,
                                      ConstantTable.get(fillStyle))
示例#12
0
 def DrawLines(self, points, fillStyle = 'oddeven'):
     return self.GC.DrawLines(points, ConstantTable.get(fillStyle) )