# Class CameraFrame

java.lang.Object
com.codename1.camera.CameraFrame

public final class CameraFrame extends Object

A single frame delivered to a `FrameListener`.

Lifetime: the byte arrays returned by this class are valid only while `FrameListener#onFrame(CameraFrame)` is on the stack. After it returns the framework may reuse or release the underlying buffers. Clone any data you need to keep.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CameraFrame(byte[] jpegBytes, byte[] rawBytes, int width, int height, int rotationDegrees, long timestampNanos, FrameFormat format)`
  Used by platform implementations.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `FrameFormat`
  `getFormat()`
  Pixel format requested for this frame.
  `int`
  `getHeight()`
  Pixel height of the frame.
  `byte[]`
  `getJpegBytes()`
  JPEG-encoded bytes for this frame.
  `byte[]`
  `getRawBytes()`
  Raw pixel bytes in the format requested via `CameraSessionOptions#frameFormat(FrameFormat)`.
  `int`
  `getRotationDegrees()`
  Clockwise rotation in degrees (0, 90, 180, 270) that should be applied to the bytes to display them upright.
  `long`
  `getTimestampNanos()`
  Monotonic timestamp in nanoseconds.
  `int`
  `getWidth()`
  Pixel width of the frame.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### CameraFrame

    public CameraFrame(byte[] jpegBytes, byte[] rawBytes, int width, int height, int rotationDegrees, long timestampNanos, FrameFormat format)
    Used by platform implementations.

- ## Method Details

  - ### getJpegBytes

    public byte[] getJpegBytes()
    JPEG-encoded bytes for this frame. Always non-null regardless of the requested `FrameFormat`; use this when encoded image data is needed. `VisionImage#fromCameraFrame(CameraFrame)` instead selects the raw buffer for NV21 and RGBA8888 frames.

  - ### getRawBytes

    public byte[] getRawBytes()
    Raw pixel bytes in the format requested via `CameraSessionOptions#frameFormat(FrameFormat)`. This is `null` for JPEG requests and may also be `null` when the current port cannot expose the requested raw format. In that case `getJpegBytes()` remains available as a fallback.

  - ### getWidth

    public int getWidth()
    Pixel width of the frame.

  - ### getHeight

    public int getHeight()
    Pixel height of the frame.

  - ### getRotationDegrees

    public int getRotationDegrees()
    Clockwise rotation in degrees (0, 90, 180, 270) that should be applied to the bytes to display them upright.

  - ### getTimestampNanos

    public long getTimestampNanos()
    Monotonic timestamp in nanoseconds. Useful for measuring inter-frame intervals.

  - ### getFormat

    public FrameFormat getFormat()
    Pixel format requested for this frame. A non-JPEG value describes `getRawBytes()` when that buffer is available; ports that cannot expose raw pixels may return `null` there while still reporting the requested format. JPEG bytes returned by `getJpegBytes()` are always JPEG-encoded regardless of this value.