function decode_rgb(packet){var width=packet[4],height=packet[5],coding=packet[6],rowstride=packet[9],data=packet[7],options=packet[10]||{};if(0<options.zlib)throw"zlib compression is not supported";if(0<options.lz4&&(data=lz4.decode(data),delete options.lz4),"rgb24"==coding)return packet[9]=4*width,packet[6]="rgb32",rgb24_to_rgb32(data,width,height,rowstride);if(rowstride==4*width)return new Uint8Array(data);for(var uint=new Uint8Array(width*height*4),psrc=0,pdst=0,row_index=0;row_index<height;row_index++)for(var psrc=row_index*rowstride,pdst=row_index*width*4,column_index=0;column_index<4*width;column_index++)uint[pdst++]=data[psrc++];return uint}function rgb24_to_rgb32(data,width,height,rowstride){var uint=new Uint8Array(width*height*4),source_index=0,target_index=0;if(rowstride==3*width)for(var source_length=data.length;source_index<source_length;)uint[target_index++]=data[source_index++],uint[target_index++]=data[source_index++],uint[target_index++]=data[source_index++],uint[target_index++]=255;else for(var row_index=0;row_index<height;row_index++)for(var source_index=row_index*rowstride,column_index=0;column_index<width;column_index++)uint[target_index++]=data[source_index++],uint[target_index++]=data[source_index++],uint[target_index++]=data[source_index++],uint[target_index++]=255;return uint}