Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-02

Help converting C code

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

leledumbo

Does the BlockRead below:

type
  TRGBQuad = record
    rgbBlue: GLubyte;
    rgbGreen: GLubyte;
    rgbRed: GLubyte;
    rgbReserved: GLubyte;
  end;

...

var
  FileHandle: File;
  BytesRead: GLuint;
  FColorPalette: PRGBQuad;
  NumberOfColours: GLuint;

...

BlockRead(FileHandle,FColorPalette^,SizeOf(TRQBQuad)*NumberOfColours,BytesRead);

corresponds to this C code:

typedef struct tagRGBQuad {
  char rgbBlue;
  char rgbGreen;
  char rgbRed;
  char rgbReserved;
} RGBQuad;

...

RGBQuad *colours;
FILE *in;
int numColours;

...

fread(colours,sizeof(RGBQuad),numColours,in);

?

View this message in context: http://old.nabble.com/Help-converting-C-code-tp27431041p27431041.html Sent from the Free Pascal - General mailing list .
Michael Van Canneyt
to leledumbo
leledumbo wrote 42 lines
Does the BlockRead below: type TRGBQuad = record rgbBlue: GLubyte; rgbGreen: GLubyte; rgbRed: GLubyte; rgbReserved: GLubyte; end; ... var FileHandle: File; BytesRead: GLuint; FColorPalette: PRGBQuad; NumberOfColours: GLuint; ... BlockRead(FileHandle,FColorPalette^,SizeOf(TRQBQuad)*NumberOfColours,BytesRead); corresponds to this C code: typedef struct tagRGBQuad { char rgbBlue; char rgbGreen; char rgbRed; char rgbReserved; } RGBQuad; ... RGBQuad *colours; FILE *in; int numColours; ... fread(colours,sizeof(RGBQuad),numColours,in);

Yes, if GLubyte=char

Michael.