# Drawing bytearray image

**URL:** https://forum.kirupa.com/t/drawing-bytearray-image/289552
**Category:** flash
**Created:** [June 1, 2009, 8:42pm UTC](https://forum.kirupa.com/t/drawing-bytearray-image/289552 "2009-06-01T20:42:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![makportal](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@makportal](https://forum.kirupa.com/u/makportal)
#### Post date: [June 1, 2009, 8:42pm UTC](https://forum.kirupa.com/t/drawing-bytearray-image/289552/1 "2009-06-01T20:42:41Z")

</div>

Hi

I’m having problems with having my bytearray (which is an image) drawn into a sprite. This is my attempt so far:

```php

var imgB:BitmapData = new BitmapData(271, 278, true, 0xff0000);
imgB.setPixels(new Rectangle(0,0,271,278), $imgData);
$image.graphics.beginBitmapFill(imgB,new Matrix(), false, true);

```

My byteArray is $imgData, and the sprite that I want to draw to is $image.  
When I run the above code I get EOF error:

```auto
Error: Error #2030: End of file was encountered.
	at flash.display::BitmapData/setPixels()

```

This is somehow related to the fact that the rectangle im setting is too large. However the image is 271x278, and also when I try to load the $imgData in a uiloader it works fine - the image is shown!

If I decrease the rectangle size to 20 x20 nothing is being drawn.  
Any thoughts?

Thank you
