Recent

Author Topic: INVALID HORIZONTAL PIXEL INDEX 1  (Read 12082 times)

suleyman

  • New Member
  • *
  • Posts: 11
INVALID HORIZONTAL PIXEL INDEX 1
« on: December 16, 2012, 04:20:49 pm »
Hi guys,

if i try to use an image on my program, lazarus get the problem:

Invalid Horizontal Pixel Index 1.



I have installed lazarus like you say it.  Now i dont know how i can solve it.



here the steps how i istalled lazarus:

1. Download FPC,FPCSOURCES,LAZARUS and Xcode

2.Install Xcode and install line tools

3. Install 1.FPC then 2.FPCsources and then 3.Lazarus

Here the Programm

I programmed two loops that compares two pictures. One for the row and one for the column. If I at column:= 0 (or 1) to w-1, I get the error message: INVALID HORIZONTAL PIXEL INDEX 1. Same as for the line.

For i:=0 to h-1 do
  begin
    For j:=0 to w-1 do
    begin
     ..  (Here I get the error message)
    End;
 end;


Thanks.
« Last Edit: December 16, 2012, 05:06:08 pm by suleyman »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #1 on: December 16, 2012, 05:48:06 pm »
Thanks for showing some code, but you don't give enough details.

Quote
..  (Here I get the error message)
<pedant mode>No you don't get the error message in .... because that will not even compile. You get an error message in code you're not showing. </pedant mode>

We don't know how you access those images, where they are stored etc.
Please show that part of the code.
My crystal ball says that either h or w are too large.

Also, you can click on the error message in the messages window on the bottom, do right-click (on Windows, perhaps cmd-click on mac or something) and select copy to clipboard. Paste the error message so people can see what the exact error is.

If the program is not confidential, it's generally better to zip up/compress the complete project (the .lpr, .lpi, .pas, .lfm etc files, but not the executable, the ppu files etc) and attach it to a post.
This way, other people can much easier look at what the exact problem is - often it is in a different place than the writer thinks...

Good luck!
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

suleyman

  • New Member
  • *
  • Posts: 11
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #2 on: December 16, 2012, 06:23:33 pm »
This programm starts well on my Tower with Windows 7:

Now the Code:

For i:=1 to 999 do
      begin


        case length(inttostr(i)) of
          3: Pfad:= inttostr(i);
          2: Pfad:='0'+inttostr(i);
          1: Pfad:='00'+inttostr(i);
        end;

         Gesamterpfad:=(Zielordner+pfad+Dateityp);



         if fileexists(gesamterpfad) then

             begin
                 application.processmessages;

                 Anfangswert:=0;
                 inc(Anz_Bilder);
                 image2.Picture.loadfromfile(Gesamterpfad);
                 Bildfarbe:=true;

                  For Zeile:=0 to Y-1 do  //Zeile is on german Row
                      begin
                           application.processmessages;

                           For Spalte:=0 to X-1 do   //Spalte is column
                               begin
                                     
                                   //  x:=image1.Width;
                                  // y:=image1.height;
                                   // AT FIRST IT WORKS FIN BUT IF SPALTE:=1 THEN I GET ERROR MESSAGE
                                  //  INVALID HORIZONTAL PIXEL INDEX 1
                     

                                  application.processmessages;

                                  Farbe1:=image1.canvas.pixels[Spalte,Zeile];  // farbe means COLOR in this point
                                  Farbe2:=image2.canvas.pixels[Spalte,Zeile];


                                  if farbe1<>farbe2 then
                                      begin
                                         // showmessage(inttostr(Zeile));
                                         // showmessage(inttostr(spalte));

                                         Bildfarbe:=false;
                                         application.processmessages;

                                         if Anfangswert=0 then
                                         begin
                                           x0:=Spalte;
                                           y0:=Zeile;

                                           max_alte_spalte:=spalte;
                                           min_alte_spalte:=Spalte;

                                           y_min:=y0;
                                           y_max:=y0;

                                           x_min:=x0;
                                           x_max:=x0;

                                           Anfangswert:=1;
                                         end;


                                        // showmessage(inttostr(spalte)+ ' ' + inttostr(alte_spalte));

                                         if Spalte>max_alte_spalte then
                                            begin
                                               max_alte_Spalte:=spalte;
                                               x_max:=Spalte;
                                            end;

                                         //showmessage(inttostr(spalte)+ ' ' + inttostr(min_alte_spalte));
                                         if Spalte<min_alte_spalte then
                                            begin
                                              min_alte_Spalte:=spalte;
                                              x_min:=min_alte_Spalte;
                                           end;


                                         if Zeile>y0 then
                                            begin
                                              y_max:=Zeile;
                                            end;

                                         if Zeile<y0 then
                                            begin
                                               y_min:=Zeile;
                                            end;

                                      end;
                               end;

                      end;

               if  Bildfarbe=false then
                 begin

                   //die Fehlerecke kennzeichnen
                   image2.canvas.Pen.color:=colorbox1.Selected;
                   image2.canvas.moveto(x_min-1,y_min-1);

                   image2.canvas.lineto(x_max+1,y_min-1);   //+1 und -1 um die
                   image2.canvas.lineto(x_max+1,y_max+1);   //Pixelfehler nicht
                   image2.canvas.lineto(x_min-1,y_max+1);   //zu überstreichen!
                   image2.canvas.lineto(x_min-1,y_min-1);

                   Image2.Picture.SaveToFile(Falsche_Bilder_Ordner+pfad+dateityp);
                   memo1.Lines.add(Pfad);

                 end;

             end;

         end;       

Here is the downloadlink:
http://www.file-upload.net/download-6935695/Aufgabe_4.rar.html
                                                                         
« Last Edit: December 16, 2012, 06:30:34 pm by suleyman »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #3 on: December 16, 2012, 06:36:19 pm »
Sorry to be a bit nasty, but:
1. When pasting code, please format it with code tags (the button marked # on the post editor toolbar).
2. Please learn to step through the code with the debugger: click next to a line of code till you get a red breakpoint.
Then run the code by pressing the Run/Run menu (F9 on windows)
When the debugger hits the breakpoint, it stops. Advance by pressing F7 or F8 (Run/Step into and Run/Step over).
You can hover your mouse over many of the variables to see their values. The View/debug menu has more interesting windows that you can use.

Using the debugger, you should be able to find out where exactly the error occurs - on which line.

3. I'm not going to look at the your code because you didn't upload a project, only a snippet of code - the form definition etc is missing and I'm too lazy to create a working program by guessing what variable types you're using, fiddling with the code and my own forms etc.
Perhaps somebody else is not as lazy as I am ;)

Freundliche Gruesse,
BigChimp
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

suleyman

  • New Member
  • *
  • Posts: 11
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #4 on: December 16, 2012, 06:46:12 pm »
It does not matter what program I use. Every time I have a Timage and one or two loops, the program begins to give me this error message. It does not matter what I program here. you need only to take a bow and chasing him through a picture and no I do not run more than the pixel size of the image. I'm just here on my PC and it runs beautifully. Google shows me that there are others who have such a problem but I can not find solution to it.

Yes it's true, I get the error message while it loops, ie compile it. But I do not know why the loop can not run more than 1 is only one Timage the case.

Thanks in advance

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #5 on: December 16, 2012, 07:41:37 pm »
I'll go through some lines:
Code: [Select]
image2.Picture.loadfromfile(Gesamterpfad);
...
application.processmessages;
...
Farbe2:=image2.canvas.pixels[Spalte,Zeile];
Are you sure that image canvas is initialized right after image is loaded? I don't really know, but i'd see if it has something like .Refresh.

You also assume that image2 is exactly same size as image1, i hope that's right. Otherwise there will be access error to pixel data, when image2 is smaller than image1.

suleyman

  • New Member
  • *
  • Posts: 11
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #6 on: December 16, 2012, 08:34:23 pm »
This is the error message:
Project1 project has triggered Exception class >>FPIImageException<<  with the message: Invalid horizontal pixel index 1.

At address 9D6CF

this ONLY happens when I do two images with each other compare as in my example. But if I upload only a picture nothing happens it does then, he throws me to the fault line, and it says:

THE CODETEXT
(http://s1.directupload.net/images/121216/tgyuzfab.png)

ERRORMESSAGE
(http://s1.directupload.net/images/121216/bal975eh.png)

ERRORLINE
(http://s7.directupload.net/images/121216/68ivgj7t.png)

« Last Edit: December 16, 2012, 08:47:04 pm by suleyman »

eny

  • Hero Member
  • *****
  • Posts: 1653
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #7 on: December 16, 2012, 09:58:51 pm »
Don't know how exactly to run the program, but it seems to run fine.
(Loading a picture in the left pane and then press 'vergleich Starten'.
All posts based on: Win10 (Win64); Lazarus 3_4  (x64) 25-05-2024 (unless specified otherwise...)

suleyman

  • New Member
  • *
  • Posts: 11
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #8 on: December 16, 2012, 10:01:05 pm »
Yes it works fine on windows 7 :)

On my mac i get the Error Message ..
« Last Edit: December 17, 2012, 06:59:10 am by suleyman »

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #9 on: December 17, 2012, 11:57:40 am »
If the program is not confidential, it's generally better to zip up/compress the complete project (the .lpr, .lpi, .pas, .lfm etc files, but not the executable, the ppu files etc) and attach it to a post.
This way, other people can much easier look at what the exact problem is - often it is in a different place than the writer thinks...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

suleyman

  • New Member
  • *
  • Posts: 11
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #10 on: December 17, 2012, 04:45:12 pm »
It is not generally the first program that I have uploaded.

It is simply the problem that I can not compare two pictures with each other.
See uploaded pictures. These are only 10 lines of programming. If I have 2 loops, one for the row for the column by hunting there, it works. But when I load two images in two different Timage I get the error message out this is also uploaded as image file.

Thanks anyway for the effort.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #11 on: December 17, 2012, 05:01:37 pm »
You don't understand. Upload the simple code with simple sample images SO YOU HAVE A REPEATABLE TEST THAT OTHERS CAN USE
(Not to mention that it's polite to try to make it as easy as possible for others to help you.)

I hope you understand this reasoning.

EDIT: Just to be achingly clear and repating myself again: I DON'T mean some random snippets of code but a complete project, with the lpr, lpi etc files. If you don't understand why...
See http://wiki.lazarus.freepascal.org/Tips_on_writing_bug_reports#Be_complete_and_always_include_a_fully_compilable_example_if_possible
« Last Edit: December 17, 2012, 05:07:02 pm by BigChimp »
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

eny

  • Hero Member
  • *****
  • Posts: 1653
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #12 on: December 17, 2012, 08:01:39 pm »
Yes it works fine on windows 7 :)
Oops, missed the Mac OS X header ;)
All posts based on: Win10 (Win64); Lazarus 3_4  (x64) 25-05-2024 (unless specified otherwise...)

JohnBinder

  • Newbie
  • Posts: 1
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #13 on: March 21, 2013, 06:42:32 pm »
Today I ran into exactly this problem.  I have a 178 x 128 pixel image and am trying to read its pixels.  The read of image.Canvas.Pixels[0, 0] does not complain but the next iteration through the inner loop which tries to read image.Canvas.Pixels[1,0] fails with an "invalid horizontal pixel index" error.  Only on Mac OS X (Carbon).  Works fine on Linux (gtk2) and Windows.  I'm running Lazarus 1.0.8.

Can anyone successfully iterate through all the pixels in an image with Lazarus 1.0.8 on Mac OS X with Carbon widgets?

John Hansen


Wolfram

  • Newbie
  • Posts: 1
Re: INVALID HORIZONTAL PIXEL INDEX 1
« Reply #14 on: April 06, 2013, 07:40:16 am »
Got the same problem a few days ago. I am using Lazarus 1.08.
When I try to do something like

co := imgThumbnail.Canvas.Pixels[x, y];
(co is TColor and imgThumbnail is a 360x240 TImage on a form)

I get a FPImageException with an "Invalid Size" message.

The same code works in Windows and I am quite sure that I used similar code without errors in OSX for the last years, too.
Maybe its really a problem since 1.08?

Thanks for any hint or workaround!

Wolfram

 

TinyPortal © 2005-2018