Encoder (131; 800) for encoding pixel values of a digital image to accomplish lossless compression of the digital image, the digital image being a 3D image with range data and comprising multiple lines of pixels with unencoded pixel values corresponding to said range data, wherein the encoder (131; 800) is configured to, for each of said multiple lines: obtain unencoded pixel values of the line; determine, for each of one or more pixels of the line, which encoding to be used for encoding of the unencoded pixel value of the pixel (x) in said lossless compression of the digital image, said determination being based on how said unencoded pixel value relates to unencoded pixel values of other, closest neighboring pixels (N1, N2) in said line, which closest neighboring pixels (N1, N2) are the two closest preceding pixels (N1, N2) to the pixel (x), wherein it is determined to use Run Length Coding, RLC, for encoding of pixel values of one or more subsequently occurring pixels of said line, if said unencoded pixel value for each of said one or more subsequently occurring pixels is the same as the unencoded pixel values of said closest neighboring pixels (N1, N2), wherein it is determined to use a first type of coding for encoding of said unencoded pixel value if said unencoded pixel value is between said unencoded pixel values of said closest neighboring pixels (N1, N2), and to use another, second type of coding for encoding of said unencoded pixel value if said unencoded pixel value is below the lowest or above the highest of said unencoded pixel values of said closest neighboring pixels (N1, N2), wherein said first type of coding is an adjusted binary coding, ABC, or a simplified adjusted binary coding, SABC, and said second type of coding is a Golomb-Rice coding configured to use a context independent k-value and a predetermined maximum code length; provide, based on the determination, encoded pixel values, which encoded pixel values are said unencoded pixel values encoded by the encoder (131; 800) and part of said lossless compression of the digital image; provide the encoded pixel values of each line comprised in a number of equal length data words; provide, in association with each line, a respective identifier identifying the start location of the line within said equal length data words comprising said encoded pixel values. obtain unencoded pixel values of the line; determine, for each of one or more pixels of the line, which encoding to be used for encoding of the unencoded pixel value of the pixel (x) in said lossless compression of the digital image, said determination being based on how said unencoded pixel value relates to unencoded pixel values of other, closest neighboring pixels (N1, N2) in said line, which closest neighboring pixels (N1, N2) are the two closest preceding pixels (N1, N2) to the pixel (x), wherein it is determined to use Run Length Coding, RLC, for encoding of pixel values of one or more subsequently occurring pixels of said line, if said unencoded pixel value for each of said one or more subsequently occurring pixels is the same as the unencoded pixel values of said closest neighboring pixels (N1, N2), wherein it is determined to use a first type of coding for encoding of said unencoded pixel value if said unencoded pixel value is between said unencoded pixel values of said closest neighboring pixels (N1, N2), and to use another, second type of coding for encoding of said unencoded pixel value if said unencoded pixel value is below the lowest or above the highest of said unencoded pixel values of said closest neighboring pixels (N1, N2), wherein said first type of coding is an adjusted binary coding, ABC, or a simplified adjusted binary coding, SABC, and said second type of coding is a Golomb-Rice coding configured to use a context independent k-value and a predetermined maximum code length; provide, based on the determination, encoded pixel values, which encoded pixel values are said unencoded pixel values encoded by the encoder (131; 800) and part of said lossless compression of the digital image; provide the encoded pixel values of each line comprised in a number of equal length data words; provide, in association with each line, a respective identifier identifying the start location of the line within said equal length data words comprising said encoded pixel values.