# fromRawBuffer static method

DocumentImage fromRawBuffer(

1. Uint8List? pixels,
2. int width,
3. int height,
4. int stride,
5. PixelFormat srcPixelFormat,
6. PixelFormat dstPixelFormat

)

Creates an Image from the specified raw data buffer.

param pixels A buffer that contains image pixels. param width The width, in pixels, of the image. param height The height, in pixels, of the image. param stride The stride, in pixels, of the image. param srcPixelFormat The pixel format of the input image. param dstPixelFormat The pixel format into which to convert the input image. return The newly created document image. throws DocumentException An error has occurred during Document Library execution.

## Implementation

    static DocumentImage fromRawBuffer(Uint8List? pixels, int width, int height, int stride, PixelFormat srcPixelFormat, PixelFormat dstPixelFormat) {
      DocumentImage documentImage = DocumentImage();
      Pointer<UnsignedChar>? pPixels;
      if (pixels != null) {
      	pPixels = calloc.allocate<UnsignedChar>(pixels.length);
      	pPixels.cast<Uint8>().asTypedList(pixels.length).setAll(0, pixels);
      }
      try {
        var err = documentSDK.id3DocumentImage_FromRawBuffer(documentImage.handle, pPixels ?? nullptr, pixels?.length ?? 0, width, height, stride, srcPixelFormat.value, dstPixelFormat.value);
        if (err != DocumentError.success.value) {
          documentImage.dispose();
          throw DocumentException(err);
        }
        return documentImage;
      } finally {
        if (pPixels != null) {
          calloc.free(pPixels);
        }
      }
    }