pvorb / scala-pnm

Scala library for working with Portable Anymap (PBM, PGM, PPM)
MIT License
1 stars 0 forks source link

Write dims PixmapBinary #2

Open AjitDingankar opened 10 years ago

AjitDingankar commented 10 years ago

IrfanView of ppm files containing "pure" RGB colors, show a value of 63 instead of 255 in Binary (but works correctly for ASCII type) and hence is much darker.

    PNM.write(new File("green-bin.ppm"), FileType.PixmapBinary, img)
    PNM.write(new File("green-txt.ppm"), FileType.PixmapASCII, img)

Sorry I can't attach sample files since GitHub doesn't support PNM. ;-)

The image data was created by the following code:

  val frameHeight = 480
  val frameWidth = 640
  val img = new BufferedImage(frameWidth, frameHeight , BufferedImage.TYPE_3BYTE_BGR)
  println("Height: " + img.getHeight() + ", Width: " + img.getWidth() + 
        ", Type: " + img.getType())
  val rgb = 255 << 8
  println("rgb = " + rgb)
  for (i <- 0 until frameHeight) 
    for (j <- 0 until frameWidth) 
      img.setRGB(i, j, rgb)
pvorb commented 10 years ago

Thank you for reporting this.

I'm very busy at the moment and for the next two weeks, so I can't look after it right now. You could either try to solve it by yourself or wait for me to do it.

AjitDingankar commented 10 years ago

Thanks Paul! I'm also busy at the moment so I'll wait for you and keep using the work-around of using ASCII  format until then.

Thanks, Ajit