Skip to content

Commit

Permalink
Add BitmapData getDataHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugh Sanderson committed Apr 29, 2023
1 parent c84c0b3 commit a1ec639
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions project/src/common/ExternalInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4722,6 +4722,18 @@ void nme_bitmap_data_get_uints8(value inSurface, value inData, int inOffset, int
}
DEFINE_PRIME6v(nme_bitmap_data_get_uints8);

value nme_bitmap_data_get_data_handle(value inSurface)
{
Surface *surf;
if (AbstractToObject(inSurface,surf))
{
const void *base = surf->GetBase();
if (base)
return alloc_abstract(gDataPointer,(void *)base);
}
return alloc_null();
}
DEFINE_PRIME1(nme_bitmap_data_get_data_handle);


void nme_bitmap_data_set_uints8(value inSurface, value inData, int inOffset, int inStride,
Expand Down
11 changes: 11 additions & 0 deletions src/nme/display/BitmapData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ class BitmapData implements IBitmapDrawable
var pf:Int = inPixelFormat==-1 ? format : inPixelFormat;
nme_bitmap_data_get_uints8(nmeHandle,dataHandle, dataOffset, dataStride, pf, subSample);
}

// Get raw pointer to image data - you can use Pointer.fromHandle(...);
public function getDataHandle() : Dynamic
{
return nme_bitmap_data_get_data_handle(nmeHandle);
}




public function getBytes(inPixelFormat:Int=-1) : ByteArray
{
var pf:Int = inPixelFormat==-1 ? format : inPixelFormat;
Expand Down Expand Up @@ -845,6 +855,7 @@ class BitmapData implements IBitmapDrawable
private static var nme_bitmap_data_set_floats32 = PrimeLoader.load("nme_bitmap_data_set_floats32", "ooiiiiiov");
private static var nme_bitmap_data_get_uints8 = PrimeLoader.load("nme_bitmap_data_get_uints8", "ooiiiiv");
private static var nme_bitmap_data_set_uints8 = PrimeLoader.load("nme_bitmap_data_set_uints8", "ooiiiiv");
private static var nme_bitmap_data_get_data_handle = PrimeLoader.load("nme_bitmap_data_get_data_handle", "oo");
}


Expand Down

0 comments on commit a1ec639

Please sign in to comment.