From: Scott S. <sco...@pi...> - 2005-11-16 20:32:28
|
Hi. I'm working on a document scanning and archive system. Documents = come off the scanner as 1-bit (black and white) 600 DPI TIFF files. = Until recently I was converting these to JPG. Then I display the image = to the user, to verify they didn't include extra space or chop anything = off, then the user can upload it to the server. Previously I had a routine that would take the tiff file, convert it to = a JPG, then open it in a DIBitmap, rescale it there to fit the screen = (leaving the original file intact) and then convert to bitmap to display = it. Now we'd like to keep the image in TIFF format all the way to the = server, for quality reasons. However, when I try open and resize the = TIFF with DIBitmap I get a solid black box where the image should be. = I'm sure I'm doing something wrong, but I'm not sure what. I'll include = the relevant code below. Please ignore the part with Image::Magic doing = the JPG conversion... I left it in so you can see what I WAS doing, and = what I am now doing... I'm wondering if I am doing something wrong, or am missing a piece of = software. But the JPG resize was working perfectly. I'd appreciate any = insight into this very much. # Log the event and convert to JPG log_event("Verifying the Image"); $image =3D Image::Magick->new; $x =3D $image->Read("C:\\tmp.tiff"); log_event("Return from ImageMagick->Read: $x"); $p =3D $image->Append(stack=3D>true); log_event("Return from ImageMagick->Append: $p"); $imgmgkres =3D $scanquality."X".$scanquality; $p->Set(density=3D>"$imgmgkres"); $p->Set(quality=3D>$jpgquality); $x =3D $p->Write("C:\\tmp.JPG"); log_event("Return from ImageMagick->Write: $x\tQuality: $jpgquality"); =20 undef $image; undef $p; # Open the file in a DIBitmap for display $dib =3D newFromFile Win32::GUI::DIBitmap('C:\\tmp.tiff'); $heightimg =3D $dib->GetHeight(); $widthimg =3D $dib->GetWidth(); $wmax =3D 750; $hmax=3D700; $hratio =3D $heightimg/$hmax; $wratio =3D $widthimg/$wmax; =20 # If image needs to be resized, resize it. if( $hratio> $wratio && $hratio > 1) { $dispdib =3D $dib -> Rescale($widthimg/$hratio, $hmax);=20 $imgwid=3D$widthimg/$hratio; $imglen=3D$hmax;} elsif( $wratio>=3D$hratio && $wratio > 1) { $dispdib =3D $dib -> Rescale($wmax, $heightimg/$wratio);=20 $imgwid=3D$wmax, $imglen=3D$heightimg/$wratio;} else {$dispdib =3D $dib; $imgwid=3D$widthimg; $imglen=3D$heightimg;} =20 $hbitmap =3D $dispdib->ConvertToBitmap(); undef $dib; undef $dispdib; =20 # Set the label and move it to center it in the space allocated. $imglbl->SetImage($hbitmap); $imglbl->Move(($wmax-$imgwid)/2, ($hmax-$imglen)/2); Scott Spearman Programmer Pikeville Medical Center Phone: 606-218-4660 Pager: 606-437-8542 Note: The information transmitted is intended only for the person or = entity to which it is addressed and may contain confidential and/or = privileged material. Any review, retransmission, dissemination or other = use of, or taking any action in reliance upon, this information by = persons or entities other than the intended recipient is prohibited. If = you received this in error, please contact the sender and delete this = material from any computer. |
From: Ariel S. <as...@ya...> - 2005-11-16 23:33:24
|
hi, i cleaned up a DIBitmap app that i had to try showing how to "fit to screen". i wrote the app that i stole this from quite a while ago and i haven't looked into why the 'rotate' doesn't work. the "fitting" business seems to work, though... you can check it out at http://www.barrack.com/dibdemo.zip which will be there for a few days... -ariel --- Scott Spearman <sco...@pi...> wrote: > Hi. I'm working on a document scanning and archive > system. Documents come off the scanner as 1-bit > (black and white) 600 DPI TIFF files. Until > recently I was converting these to JPG. Then I > display the image to the user, to verify they didn't > include extra space or chop anything off, then the > user can upload it to the server. > > Previously I had a routine that would take the tiff > file, convert it to a JPG, then open it in a > DIBitmap, rescale it there to fit the screen > (leaving the original file intact) and then convert > to bitmap to display it. Now we'd like to keep the > image in TIFF format all the way to the server, for > quality reasons. However, when I try open and > resize the TIFF with DIBitmap I get a solid black > box where the image should be. I'm sure I'm doing > something wrong, but I'm not sure what. I'll > include the relevant code below. Please ignore the > part with Image::Magic doing the JPG conversion... I > left it in so you can see what I WAS doing, and what > I am now doing... > > I'm wondering if I am doing something wrong, or am > missing a piece of software. But the JPG resize was > working perfectly. I'd appreciate any insight into > this very much. > > # Log the event and convert to JPG > log_event("Verifying the Image"); > $image = Image::Magick->new; > $x = $image->Read("C:\\tmp.tiff"); > log_event("Return from ImageMagick->Read: $x"); > $p = $image->Append(stack=>true); > log_event("Return from ImageMagick->Append: $p"); > $imgmgkres = $scanquality."X".$scanquality; > $p->Set(density=>"$imgmgkres"); > $p->Set(quality=>$jpgquality); > $x = $p->Write("C:\\tmp.JPG"); > log_event("Return from ImageMagick->Write: > $x\tQuality: $jpgquality"); > > undef $image; > undef $p; > > # Open the file in a DIBitmap for display > $dib = newFromFile > Win32::GUI::DIBitmap('C:\\tmp.tiff'); > $heightimg = $dib->GetHeight(); > $widthimg = $dib->GetWidth(); > $wmax = 750; $hmax=700; > $hratio = $heightimg/$hmax; > $wratio = $widthimg/$wmax; > > # If image needs to be resized, resize it. > if( $hratio> $wratio && $hratio > 1) > { $dispdib = $dib -> Rescale($widthimg/$hratio, > $hmax); > $imgwid=$widthimg/$hratio; $imglen=$hmax;} > elsif( $wratio>=$hratio && $wratio > 1) > { $dispdib = $dib -> Rescale($wmax, > $heightimg/$wratio); > $imgwid=$wmax, $imglen=$heightimg/$wratio;} > else {$dispdib = $dib; $imgwid=$widthimg; > $imglen=$heightimg;} > > $hbitmap = $dispdib->ConvertToBitmap(); > undef $dib; > undef $dispdib; > > # Set the label and move it to center it in the > space allocated. > $imglbl->SetImage($hbitmap); > $imglbl->Move(($wmax-$imgwid)/2, > ($hmax-$imglen)/2); > > > > Scott Spearman > Programmer > Pikeville Medical Center > Phone: 606-218-4660 > Pager: 606-437-8542 > > Note: The information transmitted is intended only > for the person or entity to which it is addressed > and may contain confidential and/or privileged > material. Any review, retransmission, dissemination > or other use of, or taking any action in reliance > upon, this information by persons or entities other > than the intended recipient is prohibited. If you > received this in error, please contact the sender > and delete this material from any computer. |
From: Scott S. <sco...@pi...> - 2005-12-01 14:01:24
|
I'm experiencing some odd behaviour with a win32::GUI app. I'm not sure if this is the best place to post, but I figured it would be a good start. I have an app that does scanning and document capture. The problem I'm experiencing is that when I click the scan button, everything executes up to the system call that gets the image. When it hits the system call it will sit and wait. I can make it continue if I give it just about ANY user intervention- moving or clicking the mouse, pressing a key on the keyboard, ect. If I just leave it, it will sometimes go on it's own, but it usually takes at least 30 seconds. I know this is relatively minor, but I also know my users are going to complain about this :( I'll include the handler and the scan function below, as both are relatively short. Note that in the DoSCAN function, the scan button (called $scan) is disabled right before the system call. When I click the button, it is immediately disabled. So I know it's getting to that point. But then it doesn't do the acquire call until I do SOMETHING, ANYTHING else. And now, without further ado: sub scan_Click() { SetSCANParams(); DoSCAN(); } sub DoSCAN() { log_event("Doing Scan!"); $append=""; for ($i=1;$i<=$scannum;$i++) { if ($i>1) {Win32::MsgBox("Please Place Page $i on the Scanner", 0, "Scanning!"); } $scancmd="C:\\Acquire\\Acquire.exe /app=\"Pikeville Medical Center\" /key=-779630267 /BW /B0 /HIDE /R$scanquality /H$scanlength /W$scanwidth /X0 /Y0 $append C:\\tmp.tiff"; $scan->Disable(); @reply = system($scancmd); log_event("I said: $scancmd"); log_event("Acquire said: ".join("\n",@reply)); $append = "/APPEND"; } DoVerify(); } I'd appreciate any input on this. Thanks Scott Spearman. |
From: Jeremy W. <jez...@ho...> - 2005-12-01 14:17:55
|
>I'll include the handler and the scan function below, as both are >relatively short. Note that in the DoSCAN function, the scan button >(called $scan) is disabled right before the system call. When I click the >button, it is immediately disabled. So I know it's getting to that point. >But then it doesn't do the acquire call until I do SOMETHING, ANYTHING >else. It might be worth trying the ShellExecute method rather than the perl system command. See http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=reference-methods This method is in Win32-GUI 1.02 and above I believe. Although it is more "fiddly" than system, it's a direct interface into the win32 API ShellExecute, and has most of the functionality. As ShellExecute is associated with your window, it might solve your issue. Cheers, jez. |
From: Scott S. <sco...@pi...> - 2005-12-01 14:49:56
|
Thanks for the idea! That seems to be more responsive, except that the ShellExecute command doesn't block until Acquire exits. Is there a way to make this block? Scott ----- Original Message ----- From: "Jeremy White" <jez...@ho...> To: <sco...@pi...>; <per...@li...> Sent: Thursday, December 01, 2005 9:17 AM Subject: RE: [perl-win32-gui-users] system call delayed? > >>I'll include the handler and the scan function below, as both are >>relatively short. Note that in the DoSCAN function, the scan button >>(called $scan) is disabled right before the system call. When I click the >>button, it is immediately disabled. So I know it's getting to that point. >>But then it doesn't do the acquire call until I do SOMETHING, ANYTHING >>else. > > It might be worth trying the ShellExecute method rather than the perl > system command. See > http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=reference-methods > > This method is in Win32-GUI 1.02 and above I believe. Although it is more > "fiddly" than system, it's a direct interface into the win32 API > ShellExecute, and has most of the functionality. As ShellExecute is > associated with your window, it might solve your issue. > > Cheers, > > jez. > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ |
From: Jeremy W. <jez...@ho...> - 2005-12-01 15:29:33
|
>Thanks for the idea! That seems to be more responsive, except that the >ShellExecute command doesn't block until Acquire exits. Is there a way to >make this block? There should be - there are lots of options which aren't documented, have a google for ShellExecute for other environments, that should help:) Cheers, jez. |
From: Robert M. <rm...@po...> - 2005-12-01 18:19:45
|
I've not used it myself, but I'd take a look at Win32::Process (standard with ActiveState Perl), which has a Wait() method to allow you to wait for a process to finish. As an aside: ShellExecute() always returns once the process it is launching has started. ShellExecuteEx() can give you a handle to the started process, that you can then use to determine when it finishes. But ShellExecuteEx() isn't implemented in Win32::GUI, so I think you'd be looking at Win32::API to get this functionality. Rob. Scott Spearman wrote: > Thanks for the idea! That seems to be more responsive, except that the > ShellExecute command doesn't block until Acquire exits. Is there a way > to make this block? > Scott > ----- Original Message ----- From: "Jeremy White" <jez...@ho...> > To: <sco...@pi...>; > <per...@li...> > Sent: Thursday, December 01, 2005 9:17 AM > Subject: RE: [perl-win32-gui-users] system call delayed? > > >> >>> I'll include the handler and the scan function below, as both are >>> relatively short. Note that in the DoSCAN function, the scan button >>> (called $scan) is disabled right before the system call. When I >>> click the button, it is immediately disabled. So I know it's getting >>> to that point. But then it doesn't do the acquire call until I do >>> SOMETHING, ANYTHING else. >> >> >> It might be worth trying the ShellExecute method rather than the perl >> system command. See >> http://perl-win32-gui.sourceforge.net/cgi-bin/docs.cgi?doc=reference-methods >> >> >> This method is in Win32-GUI 1.02 and above I believe. Although it is >> more "fiddly" than system, it's a direct interface into the win32 API >> ShellExecute, and has most of the functionality. As ShellExecute is >> associated with your window, it might solve your issue. >> >> Cheers, >> >> jez. >> >> >> >> >> ------------------------------------------------------- >> This SF.net email is sponsored by: Splunk Inc. Do you grep through log >> files >> for problems? Stop! Download the new AJAX search engine that makes >> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! >> http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click >> _______________________________________________ >> Perl-Win32-GUI-Users mailing list >> Per...@li... >> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users >> http://perl-win32-gui.sourceforge.net/ > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through log > files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > |
From: Jeremy W. <jez...@ho...> - 2005-11-17 08:43:18
|
Just a general follow up - we (everyone involved with Win32-GUI) now maintain DIBitmap (as well as AxWindow, Grid and Scintilla). DIBitmap currently uses FreeImage 3.5.1, with the latest version being 3.8.0 - see http://freeimage.sourceforge.net/ There seems to be quite a few changes between the two versions which may, or may not fix your issue. Ideally we need a "DIBitmap Champion" who's role would be to maintain and enhance DIBitmap (the same goes for Laurent's other modules). If anyone is interested, the source is available at http://cvs.sourceforge.net/viewcvs.py/perl-win32-gui/ Cheers, jez. |
From: Robert M. <rm...@po...> - 2005-11-17 19:56:52
|
Jeremy White wrote: > Just a general follow up - we (everyone involved with Win32-GUI) now > maintain DIBitmap (as well as AxWindow, Grid and Scintilla). > > DIBitmap currently uses FreeImage 3.5.1, with the latest version being > 3.8.0 - see http://freeimage.sourceforge.net/ > > There seems to be quite a few changes between the two versions which > may, or may not fix your issue. > > Ideally we need a "DIBitmap Champion" who's role would be to maintain > and enhance DIBitmap (the same goes for Laurent's other modules). If > anyone is interested, the source is available at > > http://cvs.sourceforge.net/viewcvs.py/perl-win32-gui/ If anyone is interested in championing DIBitmap, then please get in touch with Jeremy or me. rob...@us... Thanks, Rob. -- Robert May Win32::GUI, a perl extension for native Win32 applications http://perl-win32-gui.sourceforge.net/ |