Loading ...
Sorry, an error occurred while loading the content.

Re: How to get slice of window instead of whole thing? DibSect

Expand Messages
  • pkaluski
    Hi, Did you try Win32-GUI-DIBitmap? I don t have much experience with this module. I have just done few simple things. But I was under impression that the
    Message 1 of 7 , Nov 11, 2004
    • 0 Attachment
      Hi,
      Did you try Win32-GUI-DIBitmap?
      I don't have much experience with this module. I have just done few
      simple things. But I was under impression that the module is simple
      to use and works fine. It operates in Win32::GUI objects but it
      worked fine when I passed it a blessed hash reference with '-handle'
      set to window handle.
      Look under http://perso.club-internet.fr/rocherl/Win32GUI.html

      -Piotr
    • Nicole Sheldon
      Piotr - Thanks!!! You are a lifesaver. Here is my test script: #!/usr/bin/perl -w # filename: testWin32GuiDIBitmap.pl ### Declarations ### use
      Message 2 of 7 , Nov 12, 2004
      • 0 Attachment
        Piotr -

        Thanks!!! You are a lifesaver.


        Here is my test script:

        #!/usr/bin/perl -w
        # filename: testWin32GuiDIBitmap.pl


        ### Declarations ###
        use Win32::GUI::DIBitmap;
        use Time::HiRes qw(usleep ualarm gettimeofday
        tv_interval);


        ### Process Profiler ###
        ($seconds1, $microseconds1) = gettimeofday;


        ### Core ###
        $filename="c:\\ocr\\dev\\test.bmp";
        $out="c:\\ocr\\dev\\out.bmp";
        $dib = newFromFile Win32::GUI::DIBitmap ($filename);
        $height=$dib->GetHeight();
        $width=$dib->GetWidth();
        for($h=0;$h<$height;$h++) {
        for($w=0;$w<$width;$w++) {

        $p=$dib->GetPixel($w,$h);
        $hexp = sprintf("%X", $p);
        my $r=reverse((chop $hexp).(chop $hexp));

        $r=255-hex($r); # invert the image to test
        image processing
        $dib->SetPixel($w,$h,$r,$r,$r);
        }
        }

        print "width: $w, height $h\n";
        $dib->SaveToFile($out);


        ### Process Profiler ###
        ($seconds2, $microseconds2) = gettimeofday;
        $eum=$microseconds2-$microseconds1;
        $es=$seconds2-$seconds1;
        $sec=$eum / 1000000;
        print "seconds elapsed: $es, microseconds: $eum ($sec
        of a second)\n";



        I have been looking for this module for a long time
        now. Thank you much for pointing it out to me.


        Regards,

        Nicole


        --- pkaluski <pkaluski@...> wrote:

        >
        > Hi,
        > Did you try Win32-GUI-DIBitmap?
        > I don't have much experience with this module. I
        > have just done few
        > simple things. But I was under impression that the
        > module is simple
        > to use and works fine. It operates in Win32::GUI
        > objects but it
        > worked fine when I passed it a blessed hash
        > reference with '-handle'
        > set to window handle.
        > Look under
        > http://perso.club-internet.fr/rocherl/Win32GUI.html
        >
        > -Piotr
        >
        >
        >
        >
      • snikki326
        I figured out the answer to this and never posted it: # example PERL subroutine sub getBMP { # gets specified section of visible window my
        Message 3 of 7 , Jan 24, 2005
        • 0 Attachment
          I figured out the answer to this and never posted it:


          # example PERL subroutine <cut and paste>
          sub getBMP { # gets specified section of visible window
          my $description = shift; # ex: "Yahoo!"
          my $filename = shift; # output filename

          $ds = new Win32::GuiTest::DibSect();
          @array = (0,0,100,100);
          $ref = \@array;
          my @windows = FindWindowLike(0, $description,0);
          for (@windows) {
          SetForegroundWindow($_);
          $ds->CopyClient($_,$ref); #uses a reference to array
          #$ds->CopyWindow($_);
          #$ds->ToGrayScale();
          $file=$filename.".bmp";
          $ds->SaveAs("$file");
          #$ds->ToClipboard();
          }
          }

          it is really quite simple - but maybe not to a beginner.


          N


          --- In perlguitest@yahoogroups.com, Nicole Sheldon <snikki326@y...>
          wrote:
          >
          > Piotr -
          >
          > Thanks!!! You are a lifesaver.
          >
          >
          > Here is my test script:
          >
          > #!/usr/bin/perl -w
          > # filename: testWin32GuiDIBitmap.pl
          >
          >
          > ### Declarations ###
          > use Win32::GUI::DIBitmap;
          > use Time::HiRes qw(usleep ualarm gettimeofday
          > tv_interval);
          >
          >
          > ### Process Profiler ###
          > ($seconds1, $microseconds1) = gettimeofday;
          >
          >
          > ### Core ###
          > $filename="c:\\ocr\\dev\\test.bmp";
          > $out="c:\\ocr\\dev\\out.bmp";
          > $dib = newFromFile Win32::GUI::DIBitmap ($filename);
          > $height=$dib->GetHeight();
          > $width=$dib->GetWidth();
          > for($h=0;$h<$height;$h++) {
          > for($w=0;$w<$width;$w++) {
          >
          > $p=$dib->GetPixel($w,$h);
          > $hexp = sprintf("%X", $p);
          > my $r=reverse((chop $hexp).(chop $hexp));
          >
          > $r=255-hex($r); # invert the image to test
          > image processing
          > $dib->SetPixel($w,$h,$r,$r,$r);
          > }
          > }
          >
          > print "width: $w, height $h\n";
          > $dib->SaveToFile($out);
          >
          >
          > ### Process Profiler ###
          > ($seconds2, $microseconds2) = gettimeofday;
          > $eum=$microseconds2-$microseconds1;
          > $es=$seconds2-$seconds1;
          > $sec=$eum / 1000000;
          > print "seconds elapsed: $es, microseconds: $eum ($sec
          > of a second)\n";
          >
          >
          >
          > I have been looking for this module for a long time
          > now. Thank you much for pointing it out to me.
          >
          >
          > Regards,
          >
          > Nicole
          >
          >
          > --- pkaluski <pkaluski@p...> wrote:
          >
          > >
          > > Hi,
          > > Did you try Win32-GUI-DIBitmap?
          > > I don't have much experience with this module. I
          > > have just done few
          > > simple things. But I was under impression that the
          > > module is simple
          > > to use and works fine. It operates in Win32::GUI
          > > objects but it
          > > worked fine when I passed it a blessed hash
          > > reference with '-handle'
          > > set to window handle.
          > > Look under
          > > http://perso.club-internet.fr/rocherl/Win32GUI.html
          > >
          > > -Piotr
          > >
          > >
          > >
          > >
        Your message has been successfully submitted and would be delivered to recipients shortly.