チェンジセット 1458

差分発生行の前後
無視リスト:
コミット日時:
2008/09/30 20:09:38 (5 年前)
コミッタ:
tasuku
ログメッセージ:

post layer_infos and palettes with json

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/gunyarapaint/trunk/gunyarapaint/src/gplogplayer.mxml

    r1403 r1458  
    139139  private function checkImage():void { 
    140140    if (MiscUtils.compareObject( 
    141           logcan.getPNGImage(), debugCheckPng)) { 
     141        logcan.dataForPost['image'], 
     142        debugCheckPng)) { 
    142143      Alert.show('合ってる。'); 
    143144    } else { 
  • as3/gunyarapaint/trunk/gunyarapaint/src/gunyarapaint.as

    r1403 r1458  
    1 private const DEBUG:Boolean = false; 
     1private const DEBUG:Boolean = true; 
    22 
    33import flash.events.Event; 
     
    9494      } 
    9595    } 
    96     gpCanvas = gpCanvasWindow.createCanvas(canvasWidth, canvasHeight, undoBufferSize, null, null, penDetailWindow.pen); 
     96    gpCanvas = gpCanvasWindow.createCanvas(canvasWidth, canvasHeight, undoBufferSize, null, null, penDetailWindow); 
    9797    initGunyaraPaintCanvas(); 
    9898  } 
     
    195195  canvasWidth = baseImg.width; 
    196196  canvasHeight = baseImg.height; 
    197   gpCanvas = gpCanvasWindow.createCanvas(0, 0, undoBufferSize, null, baseImg, penDetailWindow.pen); 
     197  gpCanvas = gpCanvasWindow.createCanvas(0, 0, undoBufferSize, null, baseImg, penDetailWindow); 
    198198  initGunyaraPaintCanvas(); 
    199199  this.enabled = true; 
     
    272272  new Com().postOekaki(fromTextInput.text, 
    273273                       messageTextArea.text, 
    274                        gpCanvas.getPNGImage(), 
    275                        gpCanvas.compressedLog, 
    276274                       oekakiId, 
    277                        gpCanvas.concatLayerPNGImage, 
    278                        gpCanvas.logCount 
     275                       gpCanvas.dataForPost 
    279276                      ); 
    280277} 
     
    296293private function checkPngHandler(evt:FlexEvent):void { 
    297294  if (MiscUtils.compareObject( 
    298         logcan.getPNGImage(), gpCanvas.getPNGImage())) { 
     295      logcan.dataForPost['image'], 
     296      gpCanvas.dataForPost['image'])) { 
    299297    Alert.show('合ってる。'); 
    300298  } else { 
  • as3/gunyarapaint/trunk/gunyarapaint/src/org/libspark/gunyarapaint/controls/GPCanvas.as

    r1403 r1458  
    11package org.libspark.gunyarapaint.controls 
    22{ 
    3   import com.adobe.images.PNGEncoder; 
    4    
    53  import flash.display.Bitmap; 
    64  import flash.display.BitmapData; 
     
    108  import flash.events.MouseEvent; 
    119  import flash.geom.Point; 
    12   import flash.utils.ByteArray; 
    1310   
    1411  import mx.core.UIComponent; 
    1512  import mx.managers.CursorManager; 
    1613   
     14  import org.libspark.gunyarapaint.controls.PenDetailWindowControl; 
    1715  import org.libspark.gunyarapaint.entities.GPLayerArray; 
    1816  import org.libspark.gunyarapaint.entities.GPLogger; 
     
    4644 
    4745    private var _layerWindow:GPLayerWindowControl; // レイヤのコントロール 
    48  
    49         public function GPCanvas(width:uint, height:uint, undoBufferSize:uint, logger:GPLogger, baseData:BitmapData, initPen:GPPen) 
     46    private var _penDetailWindow:PenDetailWindowControl; // ペンのコントロール。 
     47 
     48        public function GPCanvas(width:uint, height:uint, undoBufferSize:uint, logger:GPLogger, baseData:BitmapData, penDetailWindow:PenDetailWindowControl) 
    5049        { 
    5150          this.percentHeight = 100; 
     
    113112         
    114113      // ペン関連の初期化 
    115       pen = initPen; 
     114      if (penDetailWindow) { 
     115        _penDetailWindow = penDetailWindow; 
     116        _pen = penDetailWindow.pen; 
     117      } else { 
     118        _pen = new GPPen(); 
     119      } 
     120      _pen.canvas = this; 
    116121          _undoBuffer = new GPUndoBuffer(undoBufferSize, _layers); 
    117122         
     
    121126    public function set layerWindow(lw:GPLayerWindowControl):void { 
    122127      _layerWindow = lw; 
     128    } 
     129     
     130    public function set penDetailWindow(pdw:PenDetailWindowControl):void { 
     131      _penDetailWindow = pdw; 
    123132    } 
    124133 
     
    465474          return _log; 
    466475        } 
    467         public function getPNGImage():ByteArray { 
    468           return PNGEncoder.encode(_layers.combinedBitmapData); 
    469         } 
    470         public function get compressedLog():ByteArray { 
    471           return _log.getCompressedLog(); 
    472         } 
    473         public function get concatLayerPNGImage():ByteArray { 
    474           return PNGEncoder.encode(_layers.concatBitmapData); 
    475         } 
    476         public function get logCount():uint { 
    477           return _log.getLogCount(); 
    478         } 
    479          
     476        public function get dataForPost():Object { 
     477          var o:Object = _layers.dataForPost; 
     478          o['compressed_log'] = _log.getCompressedLog(); 
     479          o['log_count'] = _log.getLogCount(); 
     480          o['info']['pen_details'] = [_penDetailWindow.dataForPost]; // TODO: 今後はpaletteが複数 
     481          return o; 
     482        } 
    480483        public function completePlayLog():void { 
    481484      this.dispatchEvent(new Event('completePlayLog')); 
  • as3/gunyarapaint/trunk/gunyarapaint/src/org/libspark/gunyarapaint/controls/GPCanvasWindowControl.as

    r1179 r1458  
    5656    private var scrollDragStartPoint:Point; 
    5757     
    58     public function createCanvas(width:uint, height:uint, undoBufferSize:uint, logger:GPLogger, baseData:BitmapData, pen:GPPen):GPCanvas { 
     58    public function createCanvas(width:uint, height:uint, undoBufferSize:uint, logger:GPLogger, baseData:BitmapData, penDetailWindow:PenDetailWindowControl):GPCanvas { 
    5959      if (!_canvas) { 
    60         _canvas = new GPCanvas(width, height, undoBufferSize, logger, baseData, pen); 
     60        _canvas = new GPCanvas(width, height, undoBufferSize, logger, baseData, penDetailWindow); 
    6161        //_canvas.setStyle('borderColor', 0x000000); 
    6262        //_canvas.setStyle('borderStyle', 'solid'); 
  • as3/gunyarapaint/trunk/gunyarapaint/src/org/libspark/gunyarapaint/controls/PenDetailControlScript.as

    r1179 r1458  
    1 import org.libspark.gunyarapaint.entities.GPPen; 
    2  
    31import mx.containers.GridItem; 
    42import mx.core.Application; 
     
    108import mx.managers.PopUpManager; 
    119 
     10import org.libspark.gunyarapaint.entities.GPPen; 
    1211import org.sepy.controls.SColorPicker; 
    1312import org.sepy.events.SPickerEvent; 
     
    2019import org.libspark.gunyarapaint.controls.GPCanvas; 
    2120import flash.events.Event; 
     21import org.libspark.gunyarapaint.controls.PenDetailControl; 
    2222mx.core.IFlexDisplayObject; // for not erase 
    2323 
     
    278278  return _pen; 
    279279} 
     280 
     281public function get dataForPost():Object { 
     282  return { 
     283    'palettes': [ 
     284      gridItemPalette1.getStyle('backgroundColor'), 
     285      gridItemPalette2.getStyle('backgroundColor'), 
     286      gridItemPalette3.getStyle('backgroundColor'), 
     287      gridItemPalette4.getStyle('backgroundColor'), 
     288      gridItemPalette5.getStyle('backgroundColor'), 
     289      gridItemPalette6.getStyle('backgroundColor'), 
     290      gridItemPalette7.getStyle('backgroundColor'), 
     291      gridItemPalette8.getStyle('backgroundColor'), 
     292      gridItemPalette9.getStyle('backgroundColor'), 
     293      gridItemPalette10.getStyle('backgroundColor'), 
     294      gridItemPalette11.getStyle('backgroundColor'), 
     295      gridItemPalette12.getStyle('backgroundColor'), 
     296      gridItemPalette13.getStyle('backgroundColor'), 
     297      gridItemPalette14.getStyle('backgroundColor'), 
     298      gridItemPalette15.getStyle('backgroundColor'), 
     299      gridItemPalette16.getStyle('backgroundColor'), 
     300      gridItemPalette17.getStyle('backgroundColor'), 
     301      gridItemPalette18.getStyle('backgroundColor'), 
     302      gridItemPalette19.getStyle('backgroundColor'), 
     303      gridItemPalette20.getStyle('backgroundColor'), 
     304      gridItemPalette21.getStyle('backgroundColor') 
     305    ] 
     306  }; 
     307} 
  • as3/gunyarapaint/trunk/gunyarapaint/src/org/libspark/gunyarapaint/controls/PenDetailWindowControl.mxml

    r1180 r1458  
    1111    return penDetail; 
    1212  } 
     13  public function get dataForPost():Object { 
     14    return [penDetail.dataForPost]; // TODO: 現在は111パレットのみだけど、配列化する 
     15  } 
    1316  </mx:Script> 
    1417</mx:TitleWindow> 
  • as3/gunyarapaint/trunk/gunyarapaint/src/org/libspark/gunyarapaint/entities/GPLayerArray.as

    r1352 r1458  
    11package org.libspark.gunyarapaint.entities 
    22{ 
     3  import com.adobe.images.PNGEncoder; 
     4 
    35  import flash.display.BitmapData; 
    46  import flash.display.BlendMode; 
     
    194196    } 
    195197     
    196     // レイヤーをそれぞれ縦に連結したBitmapDataを取得。宗原さまThank you! 
    197     public function get concatBitmapData():BitmapData { 
     198    // レイヤーをそれぞれ縦に連結したBitmapDataと、レイヤ情報が入ったObjectを取得。宗原さまThank you! 
     199    public function get dataForPost():Object { 
     200      // BitmapData 
    198201      var cb:BitmapData = new BitmapData(_width, _height * _a.length); 
     202      var info:Array = new Array(); 
    199203      var rect:Rectangle = new Rectangle(0, 0, _width, _height); 
    200204      for (var i:uint = 0; i < _a.length; i++) { 
    201205        cb.copyPixels(_a[i].bitmapData, rect, new Point(0, _height * i)); 
    202       } 
    203       return cb; 
     206        info.push({ 
     207          'lock': _a[i].lock ? 'true' : 'false', 
     208          'visible': _a[i].show ? 'true' : 'false', 
     209          'blendMode': _a[i].blendMode 
     210        }); 
     211      } 
     212      return { 
     213        'image': PNGEncoder.encode(_combinedBitmapData), 
     214        'layers_image': PNGEncoder.encode(cb), 
     215        'info': { 
     216          'layer_infos': info 
     217        } 
     218      }; 
    204219    } 
    205220 
  • as3/gunyarapaint/trunk/gunyarapaint/src/org/libspark/gunyarapaint/entities/GPLogger.as

    r1307 r1458  
    7878    public function createViewerCanvas(baseImg:BitmapData):GPCanvas { 
    7979      resetPosition(); 
    80       var pen:GPPen = new GPPen(); 
    81       var canvas:GPCanvas = new GPCanvas(width, height, undoBufferSize, this, baseImg, pen); 
     80      var canvas:GPCanvas = new GPCanvas(width, height, undoBufferSize, this, baseImg, null); 
    8281      return canvas; 
    8382    } 
  • as3/gunyarapaint/trunk/gunyarapaint/src/org/libspark/gunyarapaint/entities/GPPen.as

    r1344 r1458  
    1010  import flash.geom.Point; 
    1111   
     12  import mx.controls.Alert; 
     13   
    1214  import org.libspark.gunyarapaint.controls.GPCanvas; 
    1315  import org.libspark.gunyarapaint.controls.GPCanvasWindowControl; 
    1416  import org.libspark.gunyarapaint.controls.PenDetailControl; 
    15    
    16   import mx.controls.Alert; 
    1717 
    1818  public class GPPen 
     
    365365          _previewShape.graphics.moveTo(GPCanvas.zz(fromX), GPCanvas.zz(fromY)); 
    366366          _previewShape.graphics.lineTo(GPCanvas.zz(toX), GPCanvas.zz(toY)); 
    367         }       
     367        } 
    368368  } 
    369369} 
  • as3/gunyarapaint/trunk/nicopedia/org/libspark/nicopedia/Com.as

    r1403 r1458  
    22{ 
    33  import flash.display.DisplayObject; 
    4    
     4  import com.adobe.serialization.json.JSON; 
    55  import mx.core.UIComponent; 
    66   
     
    9090    } 
    9191     
    92     public function postOekaki(name:String, msg:String, 
    93                                image:ByteArray, log:ByteArray, ref_oekaki_id:uint, 
    94                                image_layers:ByteArray, log_count:uint):void { 
     92    public function postOekaki(name:String, msg:String, ref_oekaki_id:uint, data:Object):void { 
    9593      var r:URLRequest = new URLRequest(); 
    9694      var v:URLVariables = new URLVariables(); 
    9795      var b:ByteArray = new ByteArray(); 
    98        
    9996      v.cookie = cookie; 
    10097      v.magic = magic; 
     
    10299      v.MESSAGE = msg; 
    103100      v.ref_oekaki_id = ref_oekaki_id; 
    104       v.log_count = log_count
     101      v.log_count = data['log_count']
    105102      var form:String = v.toString(); 
    106103      b.writeUTFBytes(':' + form.length + '=' + form); 
    107       b.writeUTFBytes('&IMAGE:' + image.length + '='); 
    108       b.writeBytes(image); 
    109       b.writeUTFBytes('&IMAGE_LOG:' + log.length + '='); 
    110       b.writeBytes(log); 
    111       b.writeUTFBytes('&IMAGE_LAYERS:' + image_layers.length + '='); 
    112       b.writeBytes(image_layers); 
     104      b.writeUTFBytes('&IMAGE:' + data['image'].length + '='); 
     105      b.writeBytes(data['image']); 
     106      b.writeUTFBytes('&IMAGE_LOG:' + data['compressed_log'].length + '='); 
     107      b.writeBytes(data['compressed_log']); 
     108      b.writeUTFBytes('&IMAGE_LAYERS:' + data['layers_image'].length + '='); 
     109      b.writeBytes(data['layers_image']); 
     110      v.info = JSON.encode(data['info']); 
    113111      r.url = postUrl; 
    114       r.method = URLRequestMethod.POST;     
     112      r.method = URLRequestMethod.POST; 
    115113      r.contentType = 'application/x-nicopedia-oekaki'; 
    116114      r.data = b;