Henrixounez/vpng

vpng is not working on V 0.2.2 9881ff8

Closed this issue · 2 comments

V version: V 0.2.2 9881ff8
Example code (examples/redline.v w/ changed import):

import henrixounez.vpng
import os

// RedLine
// Adds a diagonal red line on a picture and saves it to an output file

fn main() {
	if os.args.len != 3 {
		println('Missing filename')
		println('./redline input.png output.png')
		return
	}
	mut png := vpng.read(os.args[1]) or {
		return
	}
	for i in 0..png.width {
		png.pixels[i * png.width + i] = vpng.TrueColorAlpha {
			255,
			0,
			0,
			255
		}
	}
	png.write(os.args[2])
}

V output:

/home/jeffangelion/.vmodules/henrixounez/vpng/parse.v:207:16: error: cannot use `&C.z_stream_s` as `&C.z_stream` in argument 1 to `C.inflateInit`
  205 |         next_out: out
  206 |     }
  207 |     C.inflateInit(&infstream)
      |                   ~~~~~~~~~~
  208 |     C.inflate(&infstream, 0)
  209 |     C.inflateEnd(&infstream)
/home/jeffangelion/.vmodules/henrixounez/vpng/parse.v:208:12: error: cannot use `&C.z_stream_s` as `&C.z_stream` in argument 1 to `C.inflate`
  206 |     }
  207 |     C.inflateInit(&infstream)
  208 |     C.inflate(&infstream, 0)
      |               ~~~~~~~~~~
  209 |     C.inflateEnd(&infstream)
  210 |     mut out_bytes := []byte{len: out_len}
/home/jeffangelion/.vmodules/henrixounez/vpng/parse.v:209:15: error: cannot use `&C.z_stream_s` as `&C.z_stream` in argument 1 to `C.inflateEnd`
  207 |     C.inflateInit(&infstream)
  208 |     C.inflate(&infstream, 0)
  209 |     C.inflateEnd(&infstream)
      |                  ~~~~~~~~~~
  210 |     mut out_bytes := []byte{len: out_len}
  211 |     for i in 0 .. (out_len) {
/home/jeffangelion/.vmodules/henrixounez/vpng/rotate.v:76:33: error: non-integer index `f64` (array type `[]henrixounez.vpng.Pixel`)
   74 |                 match png.pixel_type {
   75 |                     .truecolor {
   76 |                         clr_top_left := png.pixels[i_floor_y * png.width + i_floor_x] as TrueColor
      |                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   77 |                         clr_top_right := png.pixels[i_floor_y * png.width + i_ceiling_x] as TrueColor
   78 |                         clr_bottom_left := png.pixels[i_ceiling_y * png.width + i_floor_x] as TrueColor
/home/jeffangelion/.vmodules/henrixounez/vpng/rotate.v:77:34: error: non-integer index `f64` (array type `[]henrixounez.vpng.Pixel`)
   75 |                     .truecolor {
   76 |                         clr_top_left := png.pixels[i_floor_y * png.width + i_floor_x] as TrueColor
   77 |                         clr_top_right := png.pixels[i_floor_y * png.width + i_ceiling_x] as TrueColor
      |                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   78 |                         clr_bottom_left := png.pixels[i_ceiling_y * png.width + i_floor_x] as TrueColor
   79 |                         clr_bottom_right := png.pixels[i_ceiling_y * png.width + i_ceiling_x] as TrueColor
/home/jeffangelion/.vmodules/henrixounez/vpng/rotate.v:78:36: error: non-integer index `f64` (array type `[]henrixounez.vpng.Pixel`)
   76 |                         clr_top_left := png.pixels[i_floor_y * png.width + i_floor_x] as TrueColor
   77 |                         clr_top_right := png.pixels[i_floor_y * png.width + i_ceiling_x] as TrueColor
   78 |                         clr_bottom_left := png.pixels[i_ceiling_y * png.width + i_floor_x] as TrueColor
      |                                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   79 |                         clr_bottom_right := png.pixels[i_ceiling_y * png.width + i_ceiling_x] as TrueColor
   80 |
/home/jeffangelion/.vmodules/henrixounez/vpng/rotate.v:79:37: error: non-integer index `f64` (array type `[]henrixounez.vpng.Pixel`)
   77 |                         clr_top_right := png.pixels[i_floor_y * png.width + i_ceiling_x] as TrueColor
   78 |                         clr_bottom_left := png.pixels[i_ceiling_y * png.width + i_floor_x] as TrueColor
   79 |                         clr_bottom_right := png.pixels[i_ceiling_y * png.width + i_ceiling_x] as TrueColor
      |                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   80 | 
   81 |                         f_top := TrueColor {
/home/jeffangelion/.vmodules/henrixounez/vpng/rotate.v:98:33: error: non-integer index `f64` (array type `[]henrixounez.vpng.Pixel`)
   96 |                     }
   97 |                     .truecoloralpha {
   98 |                         clr_top_left := png.pixels[i_floor_y * png.width + i_floor_x] as TrueColorAlpha
      |                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   99 |                         clr_top_right := png.pixels[i_floor_y * png.width + i_ceiling_x] as TrueColorAlpha
  100 |                         clr_bottom_left := png.pixels[i_ceiling_y * png.width + i_floor_x] as TrueColorAlpha
/home/jeffangelion/.vmodules/henrixounez/vpng/rotate.v:99:34: error: non-integer index `f64` (array type `[]henrixounez.vpng.Pixel`)
   97 |                     .truecoloralpha {
   98 |                         clr_top_left := png.pixels[i_floor_y * png.width + i_floor_x] as TrueColorAlpha
   99 |                         clr_top_right := png.pixels[i_floor_y * png.width + i_ceiling_x] as TrueColorAlpha
      |                                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100 |                         clr_bottom_left := png.pixels[i_ceiling_y * png.width + i_floor_x] as TrueColorAlpha
  101 |                         clr_bottom_right := png.pixels[i_ceiling_y * png.width + i_ceiling_x] as TrueColorAlpha
/home/jeffangelion/.vmodules/henrixounez/vpng/rotate.v:100:36: error: non-integer index `f64` (array type `[]henrixounez.vpng.Pixel`)
   98 |                         clr_top_left := png.pixels[i_floor_y * png.width + i_floor_x] as TrueColorAlpha
   99 |                         clr_top_right := png.pixels[i_floor_y * png.width + i_ceiling_x] as TrueColorAlpha
  100 |                         clr_bottom_left := png.pixels[i_ceiling_y * png.width + i_floor_x] as TrueColorAlpha
      |                                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  101 |                         clr_bottom_right := png.pixels[i_ceiling_y * png.width + i_ceiling_x] as TrueColorAlpha
  102 |
/home/jeffangelion/.vmodules/henrixounez/vpng/rotate.v:101:37: error: non-integer index `f64` (array type `[]henrixounez.vpng.Pixel`)
   99 |                         clr_top_right := png.pixels[i_floor_y * png.width + i_ceiling_x] as TrueColorAlpha
  100 |                         clr_bottom_left := png.pixels[i_ceiling_y * png.width + i_floor_x] as TrueColorAlpha
  101 |                         clr_bottom_right := png.pixels[i_ceiling_y * png.width + i_ceiling_x] as TrueColorAlpha
      |                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102 | 
  103 |                         f_top := TrueColorAlpha {
/home/jeffangelion/.vmodules/henrixounez/vpng/write.v:15:16: error: array append cannot be used in an expression
   13 | 
   14 | fn signature(mut file_bytes []byte) {
   15 |     (*file_bytes) << [byte(0x89), `P`, `N`, `G`, `\r`, `\n`, 0x1a, `\n`]
      |                   ~~
   16 | }
   17 |
/home/jeffangelion/.vmodules/henrixounez/vpng/write.v:29:16: error: array append cannot be used in an expression
   27 |     len_bytes := int_to_bytes(ihdr_bytes.len - 4)
   28 |     crc_bytes := int_to_bytes(int(cs.crc(ihdr_bytes, ihdr_bytes.len)))
   29 |     (*file_bytes) << len_bytes
      |                   ~~
   30 |     (*file_bytes) << ihdr_bytes
   31 |     (*file_bytes) << crc_bytes
/home/jeffangelion/.vmodules/henrixounez/vpng/write.v:30:16: error: array append cannot be used in an expression
   28 |     crc_bytes := int_to_bytes(int(cs.crc(ihdr_bytes, ihdr_bytes.len)))
   29 |     (*file_bytes) << len_bytes
   30 |     (*file_bytes) << ihdr_bytes
      |                   ~~
   31 |     (*file_bytes) << crc_bytes
   32 | }
/home/jeffangelion/.vmodules/henrixounez/vpng/write.v:31:16: error: array append cannot be used in an expression
   29 |     (*file_bytes) << len_bytes
   30 |     (*file_bytes) << ihdr_bytes
   31 |     (*file_bytes) << crc_bytes
      |                   ~~
   32 | }
   33 |
/home/jeffangelion/.vmodules/henrixounez/vpng/write.v:36:16: error: array append cannot be used in an expression
   34 | fn iend_chunk(mut file_bytes []byte, mut cs CRC) {
   35 |     iend_bytes := [byte(`I`), `E`, `N`, `D`]
   36 |     (*file_bytes) << int_to_bytes(0)
      |                   ~~
   37 |     (*file_bytes) << iend_bytes
   38 |     (*file_bytes) << int_to_bytes(int(cs.crc(iend_bytes, iend_bytes.len)))
/home/jeffangelion/.vmodules/henrixounez/vpng/write.v:37:16: error: array append cannot be used in an expression
   35 |     iend_bytes := [byte(`I`), `E`, `N`, `D`]
   36 |     (*file_bytes) << int_to_bytes(0)
   37 |     (*file_bytes) << iend_bytes
      |                   ~~
   38 |     (*file_bytes) << int_to_bytes(int(cs.crc(iend_bytes, iend_bytes.len)))
   39 | }
/home/jeffangelion/.vmodules/henrixounez/vpng/write.v:38:16: error: array append cannot be used in an expression
   36 |     (*file_bytes) << int_to_bytes(0)
   37 |     (*file_bytes) << iend_bytes
   38 |     (*file_bytes) << int_to_bytes(int(cs.crc(iend_bytes, iend_bytes.len)))
      |                   ~~
   39 | }
   40 |
/home/jeffangelion/.vmodules/henrixounez/vpng/write.v:75:16: error: cannot use `&C.z_stream_s` as `&C.z_stream` in argument 1 to `C.deflateInit`
   73 |         next_out: out
   74 |     }
   75 |     C.deflateInit(&defstream, 9)
      |                   ~~~~~~~~~~
   76 |     C.deflate(&defstream, 4)
   77 |     C.deflateEnd(&defstream)
/home/jeffangelion/.vmodules/henrixounez/vpng/write.v:94:16: error: array append cannot be used in an expression
   92 |         }
   93 |     }
   94 |     (*file_bytes) << int_to_bytes(out_bytes.len - 4)
      |                   ~~
   95 |     (*file_bytes) << out_bytes
   96 |     (*file_bytes) << int_to_bytes(int(cs.crc(out_bytes, out_bytes.len)))
/home/jeffangelion/.vmodules/henrixounez/vpng/write.v:95:16: error: array append cannot be used in an expression
   93 |     }
   94 |     (*file_bytes) << int_to_bytes(out_bytes.len - 4)
   95 |     (*file_bytes) << out_bytes
      |                   ~~
   96 |     (*file_bytes) << int_to_bytes(int(cs.crc(out_bytes, out_bytes.len)))
   97 | }
/home/jeffangelion/.vmodules/henrixounez/vpng/write.v:96:16: error: array append cannot be used in an expression
   94 |     (*file_bytes) << int_to_bytes(out_bytes.len - 4)
   95 |     (*file_bytes) << out_bytes
   96 |     (*file_bytes) << int_to_bytes(int(cs.crc(out_bytes, out_bytes.len)))
      |                   ~~
   97 | }
   98 |

Thank you, it is fixed now in last commit ! 🙂

Sorry for vpng that was out of date, I'll try to keep up next time.