# bitmapData - setPixels / setVector difficulties

**URL:** https://forum.kirupa.com/t/bitmapdata-setpixels-setvector-difficulties/317505
**Category:** flash
**Created:** [December 22, 2010, 11:38pm UTC](https://forum.kirupa.com/t/bitmapdata-setpixels-setvector-difficulties/317505 "2010-12-22T23:38:35Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Hzle](https://avatars.discourse-cdn.com/v4/letter/h/46a35a/32.png) [@Hzle](https://forum.kirupa.com/u/Hzle)
#### Post date: [December 22, 2010, 11:38pm UTC](https://forum.kirupa.com/t/bitmapdata-setpixels-setvector-difficulties/317505/1 "2010-12-22T23:38:35Z")

</div>

Hi folks - my first question. I’m trying to get my head round bitmapData and everything you can do with it. I’m using \*\*pure AS3 \*\*at the moment

I’ve been playing with some Perlin noise examples - worked ok - and tried writing another image (png) onto the bitmapdata.

The new image is EMBEDed in the as3 code:

```auto

[Embed(source='icon.png')]
private var ImageClass:Class;
private var img:Bitmap = new ImageClass();

```

I write the perlin noise to the BitmapData thus:

```auto

var bmd:BitmapData = new BitmapData(200, 200, true, 0x00000000);
bmd.perlinNoise(baseX, baseY, octaves, seed, stitch, fractal, channels, grayscale, offsets);
var bm:Bitmap = new Bitmap(bmd);

```

Then drawing the image on like this, works:

```auto

bm.bitmapData.draw(img.bitmapData);

```

But using setPixels or setVector run into problems (“end of file encountered” for _setPixels_ or “out of range” for _setVector_). The code:

```auto

var rectangle:Rectangle = new Rectangle(0, 0, img.height, img.width);
var v:Vector.<uint> = img.bitmapData.getVector(rectangle);

bm.bitmapData.setVector(rectangle, v);

```

can anyone help? Thanks in advance  
Henry
