2016-05-15 1 views
0

Le code suivant compile avec Win32 mais produit l'erreur de compilateur Delphi E2064 côté gauche ne peut pas être attribué à lorsqu'il est compilé avec Win64.Compiler avec Win32-Ok, mais avec Win64-Erreur de compilateur E2064

type 
    PRGB24 = ^TRGB24; 

    TRGB24 = record 
    B, G, R: Byte; 
    end; 

    PRGBArray = ^TRGBArray; 
    TRGBArray = array [Word] of TRGB24; 

procedure TFormCurves.ApplyCurve(Src: TIEBitmap); 
var 
    iRGBArray: PRGBArray; 
    SFill, X, Y: Integer; 
begin 
    if not AImageLoaded then 
    Exit; 
    iRGBArray := PRGBArray(Src.Scanline[0]); 
    SFill := Integer(Src.Scanline[1]) - Integer(iRGBArray); 
    for Y := 0 to Src.Height - 1 do 
    begin 
    for X := 0 to Src.Width - 1 do 
    begin 
     iRGBArray[X].R := ALUT[0, ALUT[1, iRGBArray[X].R]]; 
     iRGBArray[X].G := ALUT[0, ALUT[2, iRGBArray[X].G]]; 
     iRGBArray[X].B := ALUT[0, ALUT[3, iRGBArray[X].B]]; 
    end; 
    Inc(Integer(iRGBArray), SFill);//compiler error E2064 left side cannot be assigned to 
    end; 
end; 

procedure TFormCurves.GetHist; 
var 
    iRGBArray: PRGBArray; 
    X, Y, SFill: Integer; 
    iIEBitmap: TIEBitmap; 
    iRGB: TRGB24; 
    R, G, B, l: Byte; 
begin 
    if not AImageLoaded then 
    Exit; 
    for Y := 0 to 3 do 
    begin 
    AMaxHistory[Y] := 0; 
    for X := 0 to 255 do 
     AHistory[Y, X] := 0; 
    end; 
    iIEBitmap := imgView.IEBitmap; 
    iRGBArray := PRGBArray(iIEBitmap.Scanline[0]); 
    SFill := Integer(iIEBitmap.Scanline[1]) - Integer(iRGBArray); 
    for Y := 0 to iIEBitmap.Height - 1 do 
    begin 
    for X := 0 to iIEBitmap.Width - 1 do 
    begin 
     iRGB := iRGBArray[X]; 
     R := iRGB.R; 
     G := iRGB.G; 
     B := iRGB.B; 
     l := (R + G + B) div 3; 
     AHistory[0, l] := AHistory[0, l] + 1; 
     AHistory[1, R] := AHistory[1, R] + 1; 
     AHistory[2, G] := AHistory[2, G] + 1; 
     AHistory[3, B] := AHistory[3, B] + 1; 
    end; 
    Inc(Integer(iRGBArray), SFill); //compiler error E2064 left side cannot be assigned to 
    end; 
    for Y := 0 to 3 do 
    for X := 0 to 255 do 
     if AHistory[Y, X] > AMaxHistory[Y] then 
     AMaxHistory[Y] := AHistory[Y, X]; 
end; 

Comment puis-je éliminer l'erreur du compilateur avec Win64?

Répondre

2

Sur Win64, un pointeur a une largeur de 64 bits et Integer une largeur de 32 bits. Une telle distribution nécessite que les deux côtés de l'expression d'affectation aient la même taille. D'où l'erreur.

Au lieu de coulée à Integer cast à PByte.

Inc(PByte(iRGBArray), SFill);  

Tous vos autres modèles Integer sont incorrects. Vous devez saisir la taille différente de ces types. Vous pouvez utiliser le NativeInt pour les résoudre.

+0

Cela a corrigé l'erreur de compilation, mais maintenant je reçois une exception d'exécution avec Win64 avec PRGBArray (sDst) [X]: = C; Aucune erreur d'exécution avec Win32. Des idées? Si nécessaire, devrais-je poster la procédure dans une question différente? – Bill

+0

Ce code n'est pas dans la question. Voulez-vous vraiment mon avis sur le code que je ne peux pas voir? –

+0

Ok .. Je vais poster une question pour mon problème de temps d'exécution – Bill