RawImage data + Questions lazarus / 39-Graphics ---------------------------------------------------------------------- benohb · 2011-09-27 01:48 Hello Thanks to forum members Question1: Why always holds the first pixel value  183 In the 4 bytes ( Alpha)  of bitmap..? Code: [Select]procedure TForm1.Button1Click(Sender: TObject); var FPixelsData: Pbyte; ox :Integer; bitm:tbitmap; begin    bitm:= tbitmap.Create;    bitm.LoadFromFile('whiteImage.bmp');//    // PixelFormat from (any) to pf32bit //I did not find a way to convert to 32 .. I used canvas   bitm.Canvas.Rectangle(200,200,200,200);   FPixelsData:=bitm.RawImage.Data;  for  ox := 1 to  8 do begin  //rgba        writeln('bayt[',ox,']',Byte(FPixelsData^));        Inc(PByte(FPixelsData),1);  end; end; Quote bayt[1]255 bayt[2]255 bayt[3]255 bayt[4]183 <------------this Problem bayt[5]255 bayt[6]255 bayt[7]255 bayt[8]0     <------------Correct value here, and all the remaining bits...? Note:  I used  Image To read information only, without change it, to copy data to  TFastBitmap http://wiki.freepascal.org/Fast_direct_pixel_access Question2: When used ReAllocMem for size  largest memory 'Why does not the data is saved in swap partition (linux) If  i'am wrong in my information Please .. How can I use (swap partition) Question3:  Is it possible to save a piece of memory , Example (RawImage.Data) ,and load it ,Without the use  other areas in the memory...? Example; pchar := pchar(RawImage.Data) ReAllocMem(pchar,RawImage.sizeData); ///I know that this is impossible(other pointer local ) only to clarify Write(File.bak,pchar); Note: sys : linux gui  : gtk2 cpu : i386 fpc  : 2.4.2-0 [2010/11/11] lazarus :0.9.30 ---------------------------------------------------------------------- User137 · 2011-09-27 11:18 Who says colors go from 0..255  If i recall the data for each R, G, B, A has 65536 values, meaning it takes 8 bytes per pixel. (If you ask me, color channel should always be 1 byte...) There are also some functions that you can propably use to get detailed format info about the rawimage. Actually something like RawImage.Description.BitsPerPixel, RawImage.ReadChannels(rp,r,g,b,a) When it comes to rawimages and BMP format, with my game engine i went with just Canvas.Colors[]. BMP didn't follow the same rules that i could use with JPG and PNG for rawimage. ---------------------------------------------------------------------- benohb · 2011-09-27 22:45 Code: [Select]Who says colors go from 0..255 Thanks for the answer..But in the my code Print each byte alone Quotebayt[1]255 <- Red bayt[2]255 <-Green bayt[3]255 <-Blue bayt[4]183 <-Alpha in 32bit color Each channel color = 1 byte Means 4 byte (rgba)= 2^(8*4) = 4294967295 Probability And not 65536 Quotemeaning it takes 8 bytes per pixel If the 8 bytes in each pixel will be a disaster  I suppose you want to say in every 1 byte = 8-bit  http://en.wikipedia.org/wiki/RGBA QuoteActually something like RawImage.Description.BitsPerPixel, RawImage.ReadChannels(rp,r,g,b,a) is Always 32bit/4byte in pixel .......LCL  convert bitmap to 32 bit  If you use canvas General  .. problem Alpha in the first pixel does not stop my work.. Just to know is intended or bug QuoteWhen it comes to rawimages and BMP format, with my game engine i went with just Canvas.Colors[]. BMP didn't follow the same rules that i could use with JPG and PNG for rawimage. There is no JPG or PNG  Or even BMP in Memory image  ,only ...array or Stringlist or  Block Memory all data is Uncompressed ....  I speak to deal with the image ,as especially LCL lazarus Thank you