Loader can not load more than 100Mb image

air sdk 32
system window 10
I want to cut more than 100MB image .

var fs:FileStream = new FileStream();
var by:ByteArray =new ByteArray();
fs.open(file,FileMode.READ);
fs.readBytes(by);
fs.close();
fs=null;

use Loader.loadBytes API

I don’t understand what you try to do ?
cut an image? load an image ?


before it was limited by maximum width and height in pixel
but now the file size of an image that AIR can handle is limited by your CPU/RAM ressources

see BitmapData

In AIR 1.5 and Flash Player 10, the maximum size for a BitmapData object is 8,191 pixels in width or height, and the total number of pixels cannot exceed 16,777,215 pixels. (So, if a BitmapData object is 8,191 pixels wide, it can only be 2,048 pixels high.) In Flash Player 9 and earlier and AIR 1.1 and earlier, the limitation is 2,880 pixels in height and 2,880 in width.

Starting with AIR 3 and Flash player 11, the size limits for a BitmapData object have been removed. The maximum size of a bitmap is now dependent on the operating system.


Loader.loadBytes() should allow you to load a maximum of 4GB of data (eg. uint.MAX_VALUE eg. 4,294,967,295 bytes)

but Loader depends on

  • context and security, from where are you loading the data?
  • async, eg. you have to listen for events etc.

so I will ask you what event have you listened on ?
init ? asyncError ? ioError ? securityError ?

what is the behaviour when you try to load the image?
do you get an error?

[IOErrorEvent type=“ioError” bubbles=false cancelable=false eventPhase=2 text=“Error #2124: Loaded file is an unknown type.” errorID=2124]

Error loading large image

what is the format or type of the image?

2124 Loaded file is an unknown type.

indicates that the file type you try to load is not supported

if you have Cygwin or WSL try:
$ file path/to/image.ext

also check What is the equivalent to the Linux File command for windows?

simply put, even if you try to load. for example, an image.png the image might not be a PNG file
in short you can not fully trust the file extension under Windows

using a tool like file you will be able to “scan” the image and obtain its real type

for example
$ file image.png

output:

image.png: PNG image data, 1280 x 1024, 8-bit/color RGBA, non-interlaced

The file type is correct

file cg2.jpg
cg2.jpg: PC bitmap, Windows 3.x format, 8064 x 6048 x 16

first, you’re telling me you’re on Windows and now you show a screenshot from a macOS Finder

so, if you could popup a Terminal, and do a $ file cg2.jpg you will get what I mentioned before (yes file is also available on macOS)

ah great, see it indicates PC bitmap, that’s BMP file and so not supported by AIR

second, your operating system recognise that JPEG but there are many different types of JPEG, and so I can almost guarantee you that particular JPEG format is not supported by AIR

for example,
with SWF16, Flash Player 11.3 and AIR 3.3 (see release notes)
JPEG-XR support was added, but then it was not supported before

so my advice would be to take your favorite image converter or bitmap editor and convert that particular file to either another JPG, or yet another format like PNG, and test again

Win doesn’t have that tool(file). I specially upload it to MAC for testing

you are under Windows 10, install WSL
Windows Subsystem for Linux Installation Guide for Windows 10

Ha ha, I know the reason. It’s the wrong format

cg2b.jpg format is right