[Closed] PByteArray lazarus / 62-General ---------------------------------------------------------------------- Seenkao · 2025-01-31 05:49 При работе с PByteArray элемент может не рассматриваться как байт. Eng: When working with PByteArray, an element may not be treated as a byte. example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure tex_CalcAlpha(pData: PByteArray; Width, Height: Word);var  i: Integer;  wh1, nn: LongWord;begin  wh1 := Width * Height - 1;  for i := 0 to wh1 do    if pData[i * 4 + 3] = 0 Then    begin      PLongWordArray(pData)[i] := 0;         // bottom      if i + Width <= wh1 Then      begin        nn := (i + Width) * 4;        if pData[nn + 3] > 0 Then        begin          pData[i * 4]     := pData[nn];        pData[i * 4 + 1] := pData[nn + 1];          pData[i * 4 + 2] := pData[nn + 2];          continue;        end;      end;         // bottom right      if (i + 1 <= wh1) and (i + Width <= wh1) Then      begin        nn := (i + Width + 1) * 4;        if pData[nn + 3] > 0 Then        begin          pData[i * 4]     := pData[nn];          pData[i * 4 + 1] := pData[nn + 1];          pData[i * 4 + 2] := pData[nn + 2];          continue;        end;      end; if pData[nn + 3] > 0 Then generated code: Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i                mov rcx,[rbp-$08]                 mov eax,[rbp-$24]               lea rax,[rax+$03]                 cmp [rax+rcx],$00                 jnbe +$02                    jmp +$60 here's how you can fix it: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if (pData[nn + 3] and $FF) > 0 ThenCode: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i                  mov rcx,[rbp-$08]                 mov eax,[rbp-$24]                 lea rax,[rax+$03]                 mov al,[rax+rcx]                   ; <---                 cmp al,$00                       ; <---                 jnbe +$02 The PByteArray type is its own, but similar to that in sysutils: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  // Rus: указатель на массив байт.  // Eng: pointer to an array of bytes.  PByteArray     = ^TByteArray;  // Rus: массив байт.  // Eng: array of bytes.  TByteArray     = array[0..High(LongWord) shr 1 - 1] of Byte; Debian 12 Free Pascal Compiler version 3.2.2-rrelease_3_2_2-0-g0d122c4953 [2024/01/03] for x86_64 Free Pascal Compiler version 3.2.2-r0d122c49 [2024/05/30] for x86_64 Пишу чтоб обратили внимание, вероятно это не только у меня проявится и вероятно не только с данными как байт. Google translate: I am writing to draw attention to the fact that this will probably not only happen to me and probably not only with data such as bytes. ---------------------------------------------------------------------- ------------------------ Upd: Моя вина, я в очередной раз не правильно толковал происходящее. Инструкция CMP может сравнивать память с разной размерностью, всё зависит от самой инструкции. Google translate: My fault, I once again misinterpreted what was happening. The CMP instruction can compare memory with different dimensions, it all depends on the instruction itself. ---------------------------------------------------------------------- d2010 · 2025-01-31 06:12 You have  a problem with Height and width, Always when  cann set Height and width of mages, IF IF you fail too much, please --you increase iHeight+1 and  iWidth+1; of inside your Image. Please you use packedrecord of Code: [Select]Var   PByteArray     = ^TByteArray;   // Rus: массив байт.   // Eng: array of bytes.   TByteArray     = array[0..High(LongWord) shr 1 - 1] of Byte; Please you replace with word. Alyays a word aligment very good of memory. The type Byte is nice but (.8. .8.8.8 .9 *.8 .8.8 .8. Code: [Select] type   PByteArray     = ^TByteArray;   TByteArray     = packed varray[0....00] of word; Always inside your calculate all variabiles, you set Var Red:=aPByteArray^[nth] and 255; Code: [Select] type   PByteArray     = ^TByteArray;   TByteArray     = packed array[0...High(LongWord) shr 1 - 1] of byte; Eu  multumesc  (RUGACIUNEA PARINTELUI ARSENIE BOCA (de dimineata).