package Ġcom . hal cy on mobile . multi plat for mp lay ground . shared . util Ċ Ċ import Ġkotlinx . c interop . address Of Ċ import Ġkotlinx . c interop . use Pin ned Ċ import Ġplatform . Foundation . NS Data Ċ import Ġplatform . UIKit . UI Image Ċ import Ġplatform . UIKit . UI Image PNG Representation Ċ import Ġplatform . posix . memcpy Ċ Ċ actual Ġtype alias ĠImage File Ġ= ĠUI Image Ċ Ċ actual Ġfun ĠImage File . toByteArray () Ġ= ĠUI Image PNG Representation ( this )?. toByteArray () Ġ?: Ġempty Array < Byte >(). toByteArray () Ċ Ċ @ Opt In ( Experimental Unsigned Types :: class ) Ċ private Ġfun ĠNS Data . toByteArray (): ĠByteArray Ġ= ĠByteArray ( length . toInt ()). apply Ġ{ ĊĠĠĠ Ġuse Pin ned Ġ{ ĊĠĠĠĠĠĠĠ Ġmemcpy ( it . address Of ( 0 ), Ġbytes , Ġlength ) ĊĠĠĠ Ġ} Ċ }