                             putChar( x, y: y, c: 0x20)
                         }
                     }
-                    vram2Image()
+                    vram2ImageCG()
                     break
                     
                 case 0x13:

        let bytesPerRow = Int(4 * widthBits)
        let colorSpace = CGColorSpaceCreateDeviceRGB()
        let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue)
        
        

        
        let bitmapContext = CGBitmapContextCreate(nil, widthBits, heightBits, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo)!
        
        for y in 0..<height {
            for x in 0..<width {
                
                let c:UInt8 = vram[y][x]
                
                let rect = NSRect(x: x * 8, y: (height - y) * 8, width: 8, height: 8)

                let fontref = CGImageCreateWithImageInRect(image, fontRectX(c));

                CGContextDrawImage(bitmapContext, rect, CGImageCreateCopy( fontref))
                
            }
        }

        
        // ビットマップを NSImage に変換します。
        let newImageRef = CGBitmapContextCreateImage(bitmapContext)!
        let newImage = NSImage(CGImage: newImageRef, size: NSSize(width: widthBits, height: heightBits))

        
    }
    

    // lockFocusによるイメージ生成
    func vram2ImageLF() {
        
        var screenImage = NSImage(size: NSSize(width: self.width * 8,height: self.height * 8))

        screenImage.lockFocus()
        
        for y in 0..<height {
            let yp = (height - y) * 8
//            NSLog("y:\(y) yp:\(yp)")
            for x in 0..<width {
                
                let c:UInt8 = vram[y][x]

                let xp = x * 8
                let rect = NSRect(x: xp, y: yp, width: 8, height: 8)
                fontImage.drawInRect(rect,
                    fromRect: fontRectX(c),
                    operation: NSCompositingOperation.CompositeDestinationOver, fraction: 1.0)
                
            }
