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
Post a Comment