Exemplo n.º 1
0
ImageData* ImageData::create(DOMUint8ClampedArray* data, unsigned width, ExceptionState& exceptionState)
{
    unsigned lengthInPixels = 0;
    if (!validateConstructorArguments(data, width, lengthInPixels, exceptionState)) {
        ASSERT(exceptionState.hadException());
        return nullptr;
    }
    ASSERT(lengthInPixels && width);
    unsigned height = lengthInPixels / width;
    return new ImageData(IntSize(width, height), data);
}
Exemplo n.º 2
0
ImageData* ImageData::create(DOMUint8ClampedArray* data, unsigned width, unsigned height, ExceptionState& exceptionState)
{
    unsigned lengthInPixels = 0;
    if (!validateConstructorArguments(data, width, lengthInPixels, exceptionState)) {
        ASSERT(exceptionState.hadException());
        return nullptr;
    }
    ASSERT(lengthInPixels && width);
    if (height != lengthInPixels / width) {
        exceptionState.throwDOMException(IndexSizeError, "The input data byte length is not equal to (4 * width * height).");
        return nullptr;
    }
    return new ImageData(IntSize(width, height), data);
}
Exemplo n.º 3
0
PassRefPtrWillBeRawPtr<ImageData> ImageData::create(DOMUint8ClampedArray* data, unsigned width, ExceptionState& exceptionState)
{
    if (!RuntimeEnabledFeatures::imageDataConstructorEnabled()) {
        exceptionState.throwTypeError("Illegal constructor");
        return nullptr;
    }
    unsigned lengthInPixels = 0;
    if (!validateConstructorArguments(data, width, lengthInPixels, exceptionState)) {
        ASSERT(exceptionState.hadException());
        return nullptr;
    }
    ASSERT(lengthInPixels && width);
    unsigned height = lengthInPixels / width;
    return adoptRefWillBeNoop(new ImageData(IntSize(width, height), data));
}