Just recently i realized that left column of pixels in a PNG i load are same as that of right edge colums. I have a picture which has among other things yellow line on left side and red line at right. Using Rawimage to load and render it it comes up as red line on both sides starting from 3rd row of pixels (pixel at 0,1 has same color as pixel at Width-1,0, but pixel at 10,10 etc has same color as in original image). First line is correct and image itself apart that 1 column is correct. Am i using the format information wrong? Handling the data in actual bits.
Also the wiki link from other thread:
http://lazarus-ccr.sourceforge.net/docs/lcl/graphtype/trawimagedescription.htmlTrying to simplify my code a bit to see the essential:
var n: integer;
ny,n2: cardinal;
x,y,r,g,b,a: word;
rp: TRawImagePosition;
...
n:=0;
for y:=0 to tex^.Height-1 do begin
ny:=RawImage.Description.BitsPerLine*y;
for x:=0 to tex^.Width-1 do begin
n2:=ny+x*RawImage.Description.BitsPerPixel;
rp.Byte:=n2 div 8;
rp.Bit:=n2 mod 8;
RawImage.ReadChannels(rp,r,g,b,a);
r:=r div 256; g:=g div 256; b:=b div 256;
tex^.Data[n]:=r;
tex^.Data[n+1]:=g;
tex^.Data[n+2]:=b;
inc(n,3);
end;
// (edit: fixed)
end;
If i use TBitmap to load a BMP image it renders correctly but i can't use alpha-channel with BMP and its large file to use. Also canvas pixels isn't exactly fastest way to read the data.
I think i tested this to work long time ago with no errors but i keep updating lazarus svn and now unable to tell when or if this problem has just started.
edit: Aswell as PNG this acts the same way with Rawimage of JPG.
TImage is pixel perfect in whatever image or format i use.