Einzelnen Beitrag anzeigen

delphifan2004

Registriert seit: 26. Nov 2004
Ort: Dresden
267 Beiträge
 
Delphi 10.3 Rio
 
#1

Zeigerarithmetik, "Operator ist auf diesen Operandentyp nicht anwendbar" ?

  Alt Gestern, 08:45
1). col:=pbyte(scandata+x+(y*pic.width))^;

2). r:=pbyte(scandata+(y*pic.width+x)*3+0)^;

type MyImage = record data: pointer; width,height: dword; end;

wie kann ich diese aus freepascal stammenden Konstrukte für Delphi passend umstellen?


Hier die Routine in der ich das brauche:

Delphi-Quellcode:
Procedure imLoad(var pic:MyImage;name:string);
var f:file;
    xx,yy:word;
    y,x,i:dword;
    col,r,g,b,a:byte;
    NumColors:byte;
    pal:array[0..256] of packed record r,g,b:byte; end;
    scandata:pointer;
    l:dword;
begin
   a:=128;

   assign(f,name);
   {$I-}Reset(f,1);{$I+}
   if IOresult<>0 then MyError('IM file '+name+' does''nt exist');

   BlockRead(f,NumColors,1);
   BlockRead(f,xx,2);
   BlockRead(f,yy,2);

   AllocImage(pic,xx,yy);

   if NumColors>0 then begin
   {***** 256 Color Image *****}

      pal[0].r:=0;pal[0].g:=0;pal[0].b:=0;
      for i:=1 to NumColors do begin
         BlockRead(f,pal[i],3);
      end;

      getmem(scandata,pic.width*pic.height);
      if scandata=nil then gfxError('Unable to GetMEM');

      BlockRead(f,scandata^,pic.width*pic.height,l);
      if l <> (pic.width*pic.height) then MyError('Corrupt IM file');
      
      for y:=0 to pic.height-1 do
         for x:=0 to pic.width-1 do begin
            col:=pbyte(scandata+x+(y*pic.width))^;
            PutPixelRGBA(pic,x,y,pal[col].r*4,pal[col].g*4,pal[col].b*4,a);
         end;

      freemem(scandata);

   end

Geändert von delphifan2004 (Gestern um 09:14 Uhr)
  Mit Zitat antworten Zitat