       @decodeBitmaps bitmaps, keys, index+1, callBack
 
   decodeBitmapsTag: (bitmapsTag, callBack) ->
+    log "decodeBitmapsTag 1", bitmapsTag
     bitmaps = {}
     for tag in bitmapsTag.tags
       id = tag.attrs["bitmap_id"] | 0
       bitmapData = tag.attrs["pixel_data"]
       bitmaps[id] = bitmapData
 
+    log "decodeBitmapsTag 2"
     @decodeBitmaps bitmaps, Object.keys(bitmaps), 0, callBack
 
   decodeContext: (topTag, callBack) ->
+    log "decodeContext 1"
     bitmapsTag = topTag.tag "bitmaps"
 
     postDecodeBitmaps = (bitmaps)=>
+      log "decodeContext 2"
       @bitmaps = bitmaps
       callBack()
 
+    log "decodeContext 3"
     if bitmapsTag
       @decodeBitmapsTag bitmapsTag, postDecodeBitmaps
     else
       postDecodeBitmaps null
 
   decodeTopTag: (topTag, callBack) ->
+    log "decodeTopTag 1"
     @decodeContext topTag, =>
+      log "decodeTopTag 2"
       topElement = @createElementFromTag topTag
       callBack topElement
 

    return callBack bitmaps if index >= keys.length

    key = keys[index]
    EncodedImage.toImage bitmaps[key]
    .then (decodedBitmap) =>
      bitmaps[key] = if @bitmapFactory
        @bitmapFactory.newBitmap decodedBitmap
      else

  8: "bothStretch"

module.exports = class V1Loader extends BaseObject
  @singletonClass()

  @load: (data, bitmapFactory) -> @singleton.load data, bitmapFactory

  load: (data, @bitmapFactory = Canvas.Bitmap) ->
    new Promise (resolve) =>
      xbd = Xbd.parse data
      log "V1Loader.load": xbd
      topTag = xbd.tag("art_file")
      @decodeTopTag topTag, (artFile) =>
        artFile.axis = point()
