_Image

图像类,功能包括图像的创建、渲染等相关操作。 全部展开

属性展开

  • + flip : uint

    图片翻转。默认值0为不翻转,1为水平翻转,2为垂直翻转,3为水平与垂直都翻转。

    • 示例

       image.flip = 1
  • + h : uint

    图像高度。

    • 示例

       image.h = 200
  • + rect : _Rect

    截取的矩形子图像的坐标。

    • 示例

       image.rect = _Rect.new(10.5, 10.5, 100, 100)
  • + w : uint

    图像宽度。

    • 示例

       image.w = 100
  • +

    missingImage : _Image

    图片加载失败后显示的图片。

    • 示例

       miss =  _Image.new('miss.jpg')
      image.missingImage = miss
  • +

    resname : string

    图片资源文件。设置此属性会导致重新加载纹理。

    • 示例

       image.resname = 'd.bmp'

只读属性展开

  • + dummy : bool

    纹理是否读取失败(红白格)。

  • + isPlaying : bool

    视频是否正在播放。

    • 示例

       _dofile('cameracontrol.lua') 
      image = _Image.new('test.mpg')
      _app:onIdle(function(e)
      image :drawImage(0,0,100,100)
      end)
      _app:onKeyDown(function(key)
      if key == _System.KeyA then
      image:play()
      print(image.isPlaying)
      elseif key == _System.KeyZ then
      image:pause()
      elseif key == _System.KeyS then
      image:stop()
      end
      end)
  • + ready : bool

    纹理是否读取完毕(用于异步加载)。

构造方法展开

  • + function _Image(db : _DrawBoard) : _Image
  • + function _Image(resname : string) : _Image
    • 参数
    • resname : 资源文件名。
    • 示例

       image = _Image.new('?.jpg')

公共方法展开

  • + function copy(object : _Image)
    function copy(object : _DrawBoard)

    贴图复制。

    • 参数
    • object为要复制的Image

    • 示例

       image = _Image.new('stone_color.jpg')
      image2 = _Image.new()
      image2.copy(image)
  • + function draw3DImage( x1 : number, y1 : number, z1 : number, x2 : number, y2 : number, z2 : number, x3 : number, y3 : number, z3 : number, color : int )

    渲染3D图片。

    • 参数
    • ( x1, y1, z1, x2, y2, z2, x3, y3, z3 )来定义渲染的区域。 color指定图片混合颜色
    • 示例

       _dofile('cameracontrol.lua')
      _rd.camera.eye = _Vector3.new(6, 154, 230)
      image = _Image.new('stone_color.jpg')

      _app:onIdle(function(e)
      image:draw3DImage(40, 15, 0, 40, 75, 10, 70, 15, 10)
      end)
  • + function drawBillboard(x : number, y : number, z : number, w : number, h :number, color : int)

    渲染公告板。

    • 参数
    • ( x, y, z )来定义公告板的位置。
    • w : 公告板的宽度。
    • h : 公告板的高度。
    • color : 图片混合颜色

    • 示例

       _dofile('cameracontrol.lua')
      _rd.camera.eye = _Vector3.new(1500, 1500, 1500)
      image = _Image.new('stone_color.jpg')

      _app:onIdle(function(e)
      image:drawBillboard(500, 500, 500, 256, 256)
      end)
  • + function drawImage(x1 : int, y1 : int, x2 : int, y2 : int, color : int)

    渲染图片。

    • 参数
    • (x1, y1, x2, y2)来定义渲染的区域。 color指定图片混合颜色
    • 示例

       image = _Image.new('stone_color.jpg')
      _app:onIdle(function(e)
      image:drawImage(400, 150, 700, 450)
      end)
  • + function pause()

    暂停视频。

    • 示例

       _dofile('cameracontrol.lua') 
      image = _Image.new('test.mpg')
      _app:onIdle(function(e)
      image :drawImage(0,0,100,100)
      end)
      _app:onKeyDown(function(key)
      if key == _System.KeyA then
      image:play()
      elseif key == _System.KeyZ then
      image:pause()
      elseif key == _System.KeyS then
      image:stop()
      end
      end)
  • + function play()

    播放视频,目前只支持mpg后缀名的视频文件。

    • 示例

       _dofile('cameracontrol.lua') 
      image = _Image.new('test.mpg')
      _app:onIdle(function(e)
      image :drawImage(0,0,100,100)
      end)
      _app:onKeyDown(function(key)
      if key == _System.KeyA then
      image:play()
      elseif key == _System.KeyZ then
      image:pause()
      elseif key == _System.KeyS then
      image:stop()
      end
      end)
  • + function processBorder(size : int, color : int)

    设置边缘的尺寸和颜色。

    • 参数
    • size : 尺寸。
    • color : 颜色值。
    • 示例

       image = _Image.new('stone_color.jpg')
      image:processBorder(1, _Color.Red)
      _app:onIdle(function(e)
      image:drawImage(400, 150, 700, 450)
      end)
  • + function processHSL(hue : uint, saturation : uint, lightness : uint)

    设置色调,饱和度和亮度。

    • 参数
    • hue : 色调。
    • saturation : 饱和度。
    • lightness : 亮度。
    • 示例

       ui = _SWFManager.new('image-processhsl-ui.swf')

      function newimage()
      image = _Image.new('stone_color.jpg')
      image:processHSL(ui.hue.value, ui.saturation.value, ui.lightness.value)
      end

      ui.hue.change = newimage
      ui.saturation.change = newimage
      ui.lightness.change = newimage
      newimage()

      _app:onIdle(function(e)
      ui._x, ui._y = _rd.w / 2200, 200_rd.h / 2
      image:drawImage(400, 150, 700, 450)
      end)
  • + function processRGB(modulate : uint, additive : uint, subtract : uint)

    设置RGB值。

    • 参数
    • modulate为乘色值。
    • additive为加色值。
    • subtract为减色值。
    • 示例

       ui = _SWFManager.new('image-processrgb-ui.swf')

      function newimage()
      image = _Image.new('stone_color.jpg')
      image:processRGB(ui.modulate.value, ui.additive.value, ui.substract.value)
      end

      ui.modulate.change = newimage
      ui.additive.change = newimage
      ui.substract.change = newimage
      newimage()

      _app:onIdle(function(e)
      ui._x, ui._y = _rd.w / 2200, 200_rd.h / 2
      image:drawImage(400, 150, 700, 450)
      end)
  • + function saveToFile(filename : string)

    把贴图保存为bmp文件。

    • 参数
    • filename为保存的文件名。
    • 示例

       _dofile('cameracontrol.lua')
      _rd.camera.eye = _Vector3.new(1500, 1500, 1500)
      image = _Image.new('stone_color.jpg')

      _app:onIdle(function(e)
      image:drawBillboard(500, 500, 500, 256, 256)
      end)
      image:saveToFile('image.bmp')
  • + function stop()

    停止视频。

    • 示例

       _dofile('cameracontrol.lua') 
      image = _Image.new('test.mpg')
      _app:onIdle(function(e)
      image :drawImage(0,0,100,100)
      end)
      _app:onKeyDown(function(key)
      if key == _System.KeyA then
      image:play()
      elseif key == _System.KeyZ then
      image:pause()
      elseif key == _System.KeyS then
      image:stop()
      end
      end)
问题反馈(登录才可以发表哦!)