BigAssCanvas:大于2880像素的bitmap

AS bitmapdata最大支持2880像素。

http://www.bit-101.com/blog/?p=1199

 

I heard through the grapevine that there are some improvements to the BitmapData class coming up in future versions of Flash, that will allow for larger sized bitmaps to be created. Currently, the largest BitmapData instance you can make is 2880 x 2880. This is fine for most uses, but every once in a while you just need something bigger.

I’ve been doing some generative art lately, and taking a page from the books of Josh Davis, Jared Tarbell, and Erik Natzke, I’ve been thinking of considering looking at maybe possibly getting some prints done. To make a decent quality, decent sized print, I believe you need more pixels than what BitmapData offers. The obvious solution is to use more bitmaps, but that can be a major pain stitching them together and so forth. So, I created a class that takes care of most of that for me.

Introducing the BigAssCanvas class.

Basically, BigAssCanvas mimics BitmapData, except that it is a display object (actually a display object container). You create a BigAssCanvas the same way you would a BitmapData, but you have virtually unlimited size:

[as]var myBigAssCanvas:BigAssCanvas = new BigAssCanvas(10000, 10000, true, 0xff000000);
addChild(myBigAssCanvas);[/as]

Note also that unlike a BitmapData, you add it directly to the display list.

Essentially what it’s doing is: If the width you specify is greater than 2880, it makes multiple columns of bitmaps. If the height is more than 2880, it makes multiple rows. That, in itself, is not such a big deal. The cooler part is that is abstracts several of the more common BitmapData methods so that you can use them without worrying about the fact that the method is actually being applied to several Bitmaps. Here’s what I have so far:

  • draw – works exactly like BitmapData.draw, including the matrix, colorTransform, blendMode, clipRect and smoothing. You’ll never know you aren’t just drawing to a BitmapData.
  • dispose – removes all bitmaps from display list and disposes of all bitmapdatas.
  • fillRect – rect, color.
  • getPixel, setPixel, getPixel32, setPixel32 – all just like in BitmapData.
  • noise – yup.
  • perlinNoise – everything except for stitch, which I don’t know if it can ever be made to work, and offsets, which could be made to work with some effort, I believe. (This one can be pretty slow for a large canvas, by the way.)
  • lock, and unlock, minus the changeRect stuff in unlock, which I never knew existed til tonite.

There are definitely more methods that could be added to this, but I think I covered the vast majority of use cases. If you want to dive in and contribute a method, go for it. It’s also totally untested apart from running the method a couple of times and seeing that it looked generally right. It’s completely undocumented, but you are smart kids, you’ll figure it out. Anyway, I made it tonite, it’s almost 2 a.m., I think it’s cool, and I’m blogging it.

Get it, use it, tell me what it breaks, fix it for me:

BigAssCanvas.as

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值