Gallery
Software
Music
Programming
Archive
Wednesday, Apr 24 Week 17

NGG Nokia Group Graphics


NGG file structure

Element Size Offset
TNokiaNggHeader 16 bytes 0 (beginning)
Data - 16

type //16-byte header, followed by pixel data in ASCII text format.
pNokiaNggHeader=^TNokiaNggHeader;
TNokiaNggHeader=packed record
uSig :longWord; //SIG_NOKIA_NGG
uVersion :word; //version (01)
uWidth :word; //width (72)
uHeight :word; //height (14)
uUnknown1 :word; //unknown #1
uUnknown2 :word; //unknown #2
uUnknown3 :word; //unknown #3
end;

const
NULL = #0;
SIG_NOKIA_NGG = $0047474E; //NGG[NULL]

Read file header into memory

//Read header from a file into preallocated buffer of a given size...
//from: http://www.mortenbs.com/delphi-read-file-header/
function readFileHeader(pFileName:pAnsiChar;pBuf:pointer;uSize:longWord):boolean;
const ac=GENERIC_READ;sh=FILE_SHARE_READ;attr=FILE_ATTRIBUTE_READONLY;
var h:THandle;n:longWord;
begin
result:=false;
if (pFileName=nil) or (pBuf=nil) or (uSize=0) then exit;
h:=windows.createFileA(pFileName,ac,sh,nil,OPEN_EXISTING,attr,0); //open read
if hINVALID_HANDLE_VALUE then begin
result:=windows.readFile(h,pBuf^,uSize,n,nil) and (n=uSize);
windows.closeHandle(h); //close
end;
end;

Read NGG file info

function ngg_fileinfo(filename:ansiString;memo:TMemo):bool;
var sz:longWord;buf:TNokiaNggHeader;
begin
result:=false;
sz:=sizeOf(TNokiaNggHeader);
if not readFileHeader(pAnsiChar(filename),@buf,sz) then exit;
with buf do begin
if uSigSIG_NOKIA_NGG then exit; //unknown format
memo.lines.add('filename='+filename);
memo.lines.add('width='+intToStr(uWidth)); //ex.: 72 px
memo.lines.add('height='+intToStr(uHeight)); //ex.: 14 px
memo.lines.add('version='+intToStr(uVersion));
end;
result:=true;
end;

Example

procedure TForm1.FormCreate(Sender: TObject);
var filename:ansiString;
begin
memo1.clear;
filename:='C:\sample.ngg';
if not ngg_fileinfo(filename,memo1) then memo1.text:='error';
end;

Related pages of NGG Nokia Group Graphics

Programming
Delphi programming
Colors and formats
File formats and fileinfo
Read file header into memory
NOL Nokia Operator Logo
BMP Bitmap file info