@@ -197,7 +197,7 @@ protected void copyPixels(byte[] source, SourceFormat sourceFormat, BufferImage
197
197
break ;
198
198
case RG :
199
199
case LUMINANCE_ALPHA :
200
- copyPixels_4BYTE_ABGR_TO_RG (source , buffer , destination .getWidth (), destination .getHeight ());
200
+ copyPixels_4BYTE_ABGR_TO_GB (source , buffer , destination .getWidth (), destination .getHeight ());
201
201
break ;
202
202
203
203
default :
@@ -219,6 +219,10 @@ protected void copyPixels(byte[] source, SourceFormat sourceFormat, BufferImage
219
219
case RGB5_A1 :
220
220
copyPixels_4BYTE_RGBA_TO_RGB5551 (source , buffer );
221
221
break ;
222
+ case RG :
223
+ case LUMINANCE_ALPHA :
224
+ copyPixels_4BYTE_ARGB_TO_GB (source , buffer , destination .getWidth (), destination .getHeight ());
225
+ break ;
222
226
default :
223
227
throw new IllegalArgumentException (
224
228
ErrorMessage .NOT_IMPLEMENTED .message + destination .getFormat ());
@@ -231,7 +235,7 @@ protected void copyPixels(byte[] source, SourceFormat sourceFormat, BufferImage
231
235
break ;
232
236
case RG :
233
237
case LUMINANCE_ALPHA :
234
- copyPixels_3BYTE_BGR_TO_RG (source , buffer , destination .getWidth (),
238
+ copyPixels_3BYTE_BGR_TO_GB (source , buffer , destination .getWidth (),
235
239
destination .getHeight ());
236
240
break ;
237
241
case RGBA :
@@ -263,7 +267,7 @@ protected void copyPixels(byte[] source, SourceFormat sourceFormat, BufferImage
263
267
break ;
264
268
case RG :
265
269
case LUMINANCE_ALPHA :
266
- copyPixels_3BYTE_BGR_TO_RG (source , buffer , destination .getWidth (),
270
+ copyPixels_3BYTE_BGR_TO_GB (source , buffer , destination .getWidth (),
267
271
destination .getHeight ());
268
272
break ;
269
273
default :
@@ -419,24 +423,24 @@ protected void copyPixels_3BYTE_BGR_TO_RGB(byte[] source, ByteBuffer destination
419
423
}
420
424
421
425
/**
422
- * Copies the 3 byte BGR to 16 bit 2 elements, RG, GB or LA depending on destination format
426
+ * Copies the 3 byte BGR to 16 bit 2 elements GB format
423
427
*
424
428
* @param source
425
429
* @param destination
426
430
* @param width
427
431
* @param height
428
432
*/
429
- protected void copyPixels_3BYTE_BGR_TO_RG (byte [] source , ByteBuffer destination , int width , int height ) {
433
+ protected void copyPixels_3BYTE_BGR_TO_GB (byte [] source , ByteBuffer destination , int width , int height ) {
430
434
int count = width * height ;
431
- byte [] rg = new byte [count * 2 ];
432
- int length = rg .length ;
435
+ byte [] gb = new byte [count * 2 ];
436
+ int length = gb .length ;
433
437
int sourceIndex = 0 ;
434
438
for (int destIndex = 0 ; destIndex < length ;) {
435
- rg [destIndex ++] = source [sourceIndex + 1 ];
436
- rg [destIndex ++] = source [sourceIndex ];
439
+ gb [destIndex ++] = source [sourceIndex + 1 ];
440
+ gb [destIndex ++] = source [sourceIndex ];
437
441
sourceIndex += 3 ;
438
442
}
439
- destination .put (rg , 0 , rg .length );
443
+ destination .put (gb , 0 , gb .length );
440
444
}
441
445
442
446
/**
@@ -480,24 +484,45 @@ protected void copyPixels_4BYTE_ABGR_TO_RGB5551(byte[] source, ByteBuffer destin
480
484
}
481
485
482
486
/**
483
- * Copies the 4 byte ABGR to 16 bit 2 ELEMENTS, RG, GB or LA depending on destination texture format.
487
+ * Copies the 4 byte ABGR to 16 bit 2 ELEMENTS GB format.
484
488
*
485
489
* @param source
486
490
* @param destination
487
491
* @param width
488
492
* @param height
489
493
*/
490
- protected void copyPixels_4BYTE_ABGR_TO_RG (byte [] source , ByteBuffer destination , int width , int height ) {
494
+ protected void copyPixels_4BYTE_ABGR_TO_GB (byte [] source , ByteBuffer destination , int width , int height ) {
495
+ int count = width * height ;
496
+ byte [] gb = new byte [count * 2 ];
497
+ int length = gb .length ;
498
+ int sourceIndex = 0 ;
499
+ for (int destIndex = 0 ; destIndex < length ;) {
500
+ gb [destIndex ++] = source [sourceIndex + 1 ];
501
+ gb [destIndex ++] = source [sourceIndex + 2 ];
502
+ sourceIndex += 4 ;
503
+ }
504
+ destination .put (gb , 0 , gb .length );
505
+ }
506
+
507
+ /**
508
+ * Copies the 4 byte ARGB to 16 bit 2 ELEMENTS GB format.
509
+ *
510
+ * @param source
511
+ * @param destination
512
+ * @param width
513
+ * @param height
514
+ */
515
+ protected void copyPixels_4BYTE_ARGB_TO_GB (byte [] source , ByteBuffer destination , int width , int height ) {
491
516
int count = width * height ;
492
- byte [] rg = new byte [count * 2 ];
493
- int length = rg .length ;
517
+ byte [] gb = new byte [count * 2 ];
518
+ int length = gb .length ;
494
519
int sourceIndex = 0 ;
495
520
for (int destIndex = 0 ; destIndex < length ;) {
496
- rg [destIndex ++] = source [sourceIndex + 2 ];
497
- rg [destIndex ++] = source [sourceIndex + 1 ];
521
+ gb [destIndex ++] = source [sourceIndex + 2 ];
522
+ gb [destIndex ++] = source [sourceIndex + 3 ];
498
523
sourceIndex += 4 ;
499
524
}
500
- destination .put (rg , 0 , rg .length );
525
+ destination .put (gb , 0 , gb .length );
501
526
}
502
527
503
528
}
0 commit comments