c# - Render 16 bits image in picturebox -


i have array consists in pixeldata extracted dicom image.

here's code:

        byte[] bytes = img.pixeldata.getframe(0).data; // img dicom image         int count = bytes.length / 2;         ushort[] words = new ushort[count];         (int = 0, p = 0; < count; i++, p += 2)         {             words[i] = bitconverter.touint16(bytes, p);         }         pixels16 = words.tolist(); //pixels16 contains pixeldata grayscale image 

now, here's question, how render picturebox??

well, don't know specifics, because depends on how want go (if performance important, need create own subclass of bitmap, otherwise, bitmap.setpixel work fine).

but essentially, need shove pixels bitmap, set picture box's image bitmap, like:

bitmap bitmap = new bitmap(width, height);  for(int y = 0;y < height;y++)    for(int x = 0;x < width;x++)        bitmap.setpixel(x,y, color.fromrgb(/* unpack r,g,b channel of pixel here */);  picturebox.image = bitmap; 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -