Recent

Author Topic: Invalid horizontal pixel index  (Read 1676 times)

user5

  • Sr. Member
  • ****
  • Posts: 357
Invalid horizontal pixel index
« on: December 16, 2019, 08:26:39 am »
    The four statements below do basically the same thing, which is to change a pixel color. The third and fourth statements occasionally fail for some unknown reason. I'm sure that x and y are never out of bounds. They are part of some code that I can run many times with no problem but sometimes they will fail even though the conditions are exactly the same as the successful runs. I would like to keep using the third and/or fourth statements because they are much faster than the other statements. When this error happens I get a critical error message which says "Invalid horizontal pixel index" and my question is: Will a try statement catch this kind of error?

 
Code: Pascal  [Select][+][-]
  1. image1.canvas.pixels[x,y] := tempbackcolor; //1
  2. mybitmap.canvas.pixels[x,y] := tempbackcolor; //2
  3. lazcolor := TColorToFPColor(tempbackcolor);
  4. lazimage.colors[x,y] := lazcolor; //3
  5. bgra.SetPixel(x,y,tempbackcolor); //4

user5

  • Sr. Member
  • ****
  • Posts: 357
Re: Invalid horizontal pixel index
« Reply #1 on: December 17, 2019, 06:37:28 am »
    I've done some research since I posted the previous message so I know that this is a rare problem but from what I've learned the index refers to a color. The reason that the 3rd and 4th statements sometimes fail may be because the color (tempbackcolor) is invalid. If the program could first make sure that tempbackcolor is a valid color before trying to change the pixel color then this problem could be avoided. In other words, if tempbackcolor <> a valid color then do something other than trying to change the color.
    Does anyone know if there's a way to do that quickly in the code?

user5

  • Sr. Member
  • ****
  • Posts: 357
Re: Invalid horizontal pixel index
« Reply #2 on: December 17, 2019, 08:50:34 am »
    The "Invalid horizontal pixel index" error happened again but it didn't happen with BGRABitmap. It occurred using the third shown technique "lazimage.colors[x,y] := lazcolor;" so I'm going to get rid of TLazIntfImage and replace it with BGRABitmap. There were two sections of code with the first one using TLazIntfImage and the second one using BGRABitmap. The error happened in the first section. BGRABitmap is pretty cool. I'd still like to know if there's a way to know if a color is a legit color.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Invalid horizontal pixel index
« Reply #3 on: December 17, 2019, 10:24:26 am »
Hi!

The "Invalid horizontal pixel index" error  happens if x < 0 or x >= the width of the image.

What do you mean with "valid color" ??

Winni

jyl

  • New member
  • *
  • Posts: 9
Re: Invalid horizontal pixel index
« Reply #4 on: January 12, 2021, 06:31:21 pm »
Strangely enough, I now systematically get this error message (but with vertical instead of horizontal, and value after index is 15), when I click the arrow next to the open button of the Lazarus IDE.
It seems to appear after I installed some packages (MQTT and its dependencies namely), that I hasted to remove and rebuilt IDE... but still present.
Maybe the problem was not coming from the installed packages...
But from where could it come?
Thanks for any suggestion...
jyl

Seenkao

  • Hero Member
  • *****
  • Posts: 546
    • New ZenGL.
Re: Invalid horizontal pixel index
« Reply #5 on: January 13, 2021, 08:29:25 am »
Добрый день!
Проверьте в первую очередь, проявляются ли данные ошибки с выключенной отладкой? Во вкладке "отладка" надо отключить так же все флаги отладки.

Eng:
Good afternoon!
Check first if these errors show up with debugging turned off? All debug flags must be disabled in the "debug" tab.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

 

TinyPortal © 2005-2018