Changeset 3588 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Sep 7, 2018 9:10:11 AM (7 years ago)
Author:
vondreele
Message:

fix old style wx.CHANGE_DIR to wx.DR_CHANGE_DIR in several places.
fix save plot bug jpeg can not be RGBA but only RGB - simplify code as distinction between jpeg & others isn't

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIIplot.py

    r3584 r3588  
    10971097            size = Page.canvas.GetSize()
    10981098            GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
    1099             if mode in ['jpeg',]:
    1100                 Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGBA,GL.GL_UNSIGNED_BYTE)
    1101                 im = Im.new("RGBA", (size[0],size[1]))
    1102             else:
    1103                 Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB,GL.GL_UNSIGNED_BYTE)
    1104                 im = Im.new("RGB", (size[0],size[1]))
     1099            Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB,GL.GL_UNSIGNED_BYTE)
     1100            im = Im.new("RGB", (size[0],size[1]))
    11051101            try:
    11061102                im.frombytes(Pix)
     
    30883084        '''
    30893085        def ClosestColorNumber(color):
    3090             '''Convert a RGB or RGBA value to the closest default Grace color
     3086            '''Convert a RGB value to the closest default Grace color
    30913087            '''
    30923088            import matplotlib.colors as mpcls
     
    71117107            else:
    71127108                dlg = wx.FileDialog(G2frame, 'Choose graphics save file',
    7113                     wildcard='Graphics file (*.'+mode+')|*.'+mode,style=wx.FD_OPEN| wx.CHANGE_DIR)
     7109                    wildcard='Graphics file (*.'+mode+')|*.'+mode,style=wx.FD_OPEN| wx.FD_CHANGE_DIR)
    71147110                try:
    71157111                    if dlg.ShowModal() == wx.ID_OK:
     
    71187114                    dlg.Destroy()           
    71197115            size = Page.canvas.GetSize()
    7120             GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
    7121             if mode in ['jpeg',]:
    7122                 Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGBA, GL.GL_UNSIGNED_BYTE)
    7123                 im = Im.new("RGBA", (size[0],size[1]))
    7124             else:
    7125                 Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB, GL.GL_UNSIGNED_BYTE)
    7126                 im = Im.new("RGB", (size[0],size[1]))
    7127             try:
    7128                 im.frombytes(Pix)
    7129             except AttributeError:
    7130                 im.fromstring(Pix)
    7131             im = im.transpose(Im.FLIP_TOP_BOTTOM)
    7132             im.save(Fname,mode)
    7133             cb.SetValue(' save as/key:')
    7134             G2frame.G2plotNB.status.SetStatusText('Drawing saved to: '+Fname,1)
     7116            if Fname:
     7117                GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
     7118                if mode in ['jpeg',]:
     7119                    Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB, GL.GL_UNSIGNED_BYTE)
     7120                    im = Im.new("RGB", (size[0],size[1]))
     7121                else:
     7122                    Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB, GL.GL_UNSIGNED_BYTE)
     7123                    im = Im.new("RGB", (size[0],size[1]))
     7124                try:
     7125                    im.frombytes(Pix)
     7126                except AttributeError:
     7127                    im.fromstring(Pix)
     7128                im = im.transpose(Im.FLIP_TOP_BOTTOM)
     7129                im.save(Fname,mode)
     7130                cb.SetValue(' save as/key:')
     7131                G2frame.G2plotNB.status.SetStatusText('Drawing saved to: '+Fname,1)
    71357132        else:
    71367133            event.key = cb.GetValue()[0]
     
    84788475            size = Page.canvas.GetSize()
    84798476            GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
    8480             if mode in ['jpeg',]:
    8481                 Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGBA, GL.GL_UNSIGNED_BYTE)
    8482                 im = Im.new("RGBA", (size[0],size[1]))
    8483             else:
    8484                 Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB, GL.GL_UNSIGNED_BYTE)
    8485                 im = Im.new("RGB", (size[0],size[1]))
     8477            Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB, GL.GL_UNSIGNED_BYTE)
     8478            im = Im.new("RGB", (size[0],size[1]))
    84868479            try:
    84878480                im.frombytes(Pix)
     
    86258618            size = Page.canvas.GetSize()
    86268619            GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1)
    8627             if mode in ['jpeg',]:
    8628                 Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGBA, GL.GL_UNSIGNED_BYTE)
    8629                 im = Im.new("RGBA", (size[0],size[1]))
    8630             else:
    8631                 Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB, GL.GL_UNSIGNED_BYTE)
    8632                 im = Im.new("RGB", (size[0],size[1]))
     8620            Pix = GL.glReadPixels(0,0,size[0],size[1],GL.GL_RGB, GL.GL_UNSIGNED_BYTE)
     8621            im = Im.new("RGB", (size[0],size[1]))
    86338622            try:
    86348623                im.frombytes(Pix)
Note: See TracChangeset for help on using the changeset viewer.