@@ -33,7 +33,7 @@ public BufferedImage capture() {
3333 MemorySegment bufferPointer = arena .allocate (ValueLayout .JAVA_BYTE , numBytes );
3434
3535 int result = Cap_captureFrame (context .getSegment (), id , bufferPointer , numBytes );
36- CaptureResult captureResult = CaptureResult .values ()[ result ] ;
36+ CaptureResult captureResult = CaptureResult .fromNative ( result ) ;
3737 if (captureResult != CaptureResult .OK ) {
3838 throw new CaptureException ("Error capturing frame: " + result );
3939 }
@@ -87,7 +87,7 @@ public PropertyLimits getPropertyLimits(CaptureProperty property) {
8787 MemorySegment defaultValuePointer = arena .allocate (ValueLayout .JAVA_INT );
8888
8989 int result = Cap_getPropertyLimits (context .getSegment (), id , property .value (), minPointer , maxPointer , defaultValuePointer );
90- CaptureResult captureResult = CaptureResult .values ()[ result ] ;
90+ CaptureResult captureResult = CaptureResult .fromNative ( result ) ;
9191 return switch (captureResult ) {
9292 case OK -> new PropertyLimits (
9393 minPointer .get (ValueLayout .JAVA_INT , 0 ),
@@ -112,7 +112,7 @@ public int getProperty(CaptureProperty property) {
112112 try (Arena arena = Arena .ofConfined ()) {
113113 MemorySegment valuePointer = arena .allocate (ValueLayout .JAVA_INT );
114114 int result = Cap_getProperty (context .getSegment (), id , property .value (), valuePointer );
115- CaptureResult captureResult = CaptureResult .values ()[ result ] ;
115+ CaptureResult captureResult = CaptureResult .fromNative ( result ) ;
116116 return switch (captureResult ) {
117117 case OK -> valuePointer .get (ValueLayout .JAVA_INT , 0 );
118118 case PROPERTY_NOT_SUPPORTED -> throw new CaptureException ("Property " + property + " is not supported by this stream." );
@@ -130,7 +130,7 @@ public int getProperty(CaptureProperty property) {
130130 */
131131 public void setProperty (CaptureProperty property , int value ) {
132132 int result = Cap_setProperty (context .getSegment (), id , property .value (), value );
133- CaptureResult captureResult = CaptureResult .values ()[ result ] ;
133+ CaptureResult captureResult = CaptureResult .fromNative ( result ) ;
134134 switch (captureResult ) {
135135 case OK -> {}
136136 case PROPERTY_NOT_SUPPORTED -> throw new CaptureException ("Property " + property + " is not supported by this stream." );
@@ -149,7 +149,7 @@ public boolean getAutoProperty(CaptureProperty property) {
149149 try (Arena arena = Arena .ofConfined ()) {
150150 MemorySegment valuePointer = arena .allocate (ValueLayout .JAVA_INT );
151151 int result = Cap_getAutoProperty (context .getSegment (), id , property .value (), valuePointer );
152- CaptureResult captureResult = CaptureResult .values ()[ result ] ;
152+ CaptureResult captureResult = CaptureResult .fromNative ( result ) ;
153153 return switch (captureResult ) {
154154 case OK -> valuePointer .get (ValueLayout .JAVA_INT , 0 ) == 1 ;
155155 case PROPERTY_NOT_SUPPORTED -> throw new CaptureException ("Property " + property + " is not supported by this stream." );
@@ -167,7 +167,7 @@ public boolean getAutoProperty(CaptureProperty property) {
167167 */
168168 public void setAutoProperty (CaptureProperty property , boolean enable ) {
169169 int result = Cap_setAutoProperty (context .getSegment (), id , property .value (), enable ? 1 : 0 );
170- CaptureResult captureResult = CaptureResult .values ()[ result ] ;
170+ CaptureResult captureResult = CaptureResult .fromNative ( result ) ;
171171 switch (captureResult ) {
172172 case OK -> {}
173173 case PROPERTY_NOT_SUPPORTED -> throw new CaptureException ("Property " + property + " is not supported by this stream." );
@@ -193,7 +193,7 @@ public boolean isOpen() {
193193 @ Override
194194 public void close () {
195195 int result = Cap_closeStream (context .getSegment (), id );
196- CaptureResult captureResult = CaptureResult .values ()[ result ] ;
196+ CaptureResult captureResult = CaptureResult .fromNative ( result ) ;
197197 if (captureResult != CaptureResult .OK ) {
198198 throw new CaptureException ("Error closing capture stream: " + result );
199199 }
0 commit comments