Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
brichard  
#1 Posted : Wednesday, January 12, 2005 12:57:00 AM(UTC)
brichard

Rank: Member

Groups: Member
Joined: 11/17/2004(UTC)
Posts: 6

I'm trying to do some testing but I'm having issues printing to a "Zebra P310i printer" from Aurigma. The printer prints, but the picture is blank??

At first I suspected my code, but the odd thing is, I can use this identical code to print to 3 other printers.

So, then I obviously suspected the Printer. But odddly enough, I can print to this printer from every other application on my machine; Notepad, Word, Vb, etc... So this led me back to the code.

This is when things started to get more compliated; I'm using aurigma's trial app to see if this product is a viable solution and the app does print "Aurigma Graphics Mill 2.0 Trial" in the upper left hand corner, but the bitmap is completely missing. I ran this same exact code to 3 other printers and they all worked but not on this particular printer? So it would appear that aurigma can print to this printer?

I then tried working around aurigma's "DrawOnHdc" call and used the vb Printer.PaintPicture using Aurigma's object. This miracously worked!??? But I'm not sure how?

Below is the code that works and then the code that doesn't work. Could there be some functionality conflict with the driver? But if so, how does every other application work?

Another piece of useful information. I added a "watch" to the printer object and compared the printer object when it worked with a Fargo printer and when it didn't work with the Zebra printer. The Printer Object was almost Identical except for the height and width were about 20 pixels off.

Code that doesn't work on Zebra printer through Aurigma:
Code:
   Dim prnHt As Integer
   Dim prnWt As Integer

   BitmapViewer1.Bitmap.LoadFromFile "C:\2005.bmp"

   Printer.ScaleMode = vbPixels
   prnHt = Printer.ScaleY(1#, vbInches, vbPixels)  
   prnWt = Printer.ScaleX(1#, vbInches, vbPixels)  

   BitmapViewer1.Bitmap.DrawOnHdc Printer.hdc, 0, 0, prnWt, prnHt, , , prnWt, prnHt, 
       CombineModeCopy, InterpolationModeNearestNeighbour


Code that works (just to print a portion of the bitmap from vb):
Code:
    Dim prnHt As Integer
    Dim prnWt As Integer

   Printer.ScaleMode = vbPixels
   Me.ScaleMode = vbPixels

   prnHt = Printer.ScaleY(1#, vbInches, vbPixels)  '-jcl-09/27/04
   prnWt = Printer.ScaleX(1#, vbInches, vbPixels)   '-jcl-09/27/04
   Printer.Print ""

   BitmapViewer1.Bitmap.Transforms.Resize 300, 300
   Printer.PaintPicture BitmapViewer1.Bitmap.Data.Picture, 0, 0, prnWt, prnHt, , , prnWt, prnHt
     
   Printer.EndDoc




Any help would be greatly appreciated.
-Brian

Edited by user Sunday, December 23, 2007 4:54:18 PM(UTC)  | Reason: Not specified

Fedor  
#2 Posted : Thursday, January 13, 2005 2:49:00 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,548

Thanks: 5 times
Was thanked: 59 time(s) in 58 post(s)
Brian,

We will check it today and will let you know.
Best regards,
Fedor Skvortsov
Andrew  
#3 Posted : Thursday, January 13, 2005 6:30:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 866

Thanks: 2 times
Was thanked: 26 time(s) in 26 post(s)
Hello Brian,

It seems the problem is in particular printer driver. It is possible it does not handle copying pixels to HDC with some particular pixel format. By the way, what is a pixel format of your bitmap?

The Printer object of the Visual Basic does more than just drawing the bitmap on HDC. It do the scaling, etc, and it seems it also converts the bitmap to 24 or 32 bit RGB pixel format. Some of the operation seems to "repair" the bitmap (which "incorrect" from the point of view of the printer).

To check these suggestions, try the following: convert the bitmap to 24-bit RGB before using DrawOnHdc.
brichard  
#4 Posted : Thursday, January 13, 2005 8:12:00 PM(UTC)
brichard

Rank: Member

Groups: Member
Joined: 11/17/2004(UTC)
Posts: 6

Thanks for the quick reply!

The format is 24-bit RGB.

I (previously) tried converting the image to 3 different formats before printing. 24, 32, CMYK. None of these seem to make a difference.

I also saw a solution on aurigma that spoke about bitmap formats and that there was some bug that was caused when you draw an image from a picture box. It was setting the Alpha channel to 0 and therefore making the image transparent. I tried setting the alpha chanel to 255 after I converted the image to 32 bit, but still no difference.

I realize there could be a printer driver issue so I have posted this issue with Zebra as well. Still waiting on a response from them.

Forgive me for playing a little devils advocate; But then why does the "Aurigma Graphics Mill trial" print in the upper left hand corner? How is that image/text setup to print to the printer.

Note: We also print bar codes and text directly to the printer and these work as well, the only thing that doesn't work is the bitmap through drawonHDC.


Any other suggestion would be greatly appreciated!!

-Brian
Andrew  
#5 Posted : Thursday, January 13, 2005 9:02:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 866

Thanks: 2 times
Was thanked: 26 time(s) in 26 post(s)
I (previously) tried converting the image to 3 different formats before printing. 24, 32, CMYK. None of these seem to make a difference.

Well... Sounds weird.

But I think that drawing the bitmap through the Picture.PaintPicture is good solution. Even if it worked, it would be better to use Picture.PaintPicture rather than DrawOnHdc, because it already implements scaling. So no need to convert pixels to inches, etc.

Forgive me for playing a little devils advocate; But then why does the "Aurigma Graphics Mill trial" print in the upper left hand corner? How is that image/text setup to print to the printer.

The trial text is drawn at the HDC in different way than the bitmap. It is not drawn as a bitmap, but as a text string (using the TextOut WinAPI function).

In other words it is drawn via the same mechanism as using the DrawText method of the Graphics object.
brichard  
#6 Posted : Thursday, January 13, 2005 9:11:00 PM(UTC)
brichard

Rank: Member

Groups: Member
Joined: 11/17/2004(UTC)
Posts: 6

Thanks for the feedback.

One last question. If I use the Printer.PaintPicture will that output to the printer in the same resolution and detail as DrawonHDC? I only ask because you said that PaintPicture does some scaling and I didn't know if aurigma was outputing with a higher quality?

I'm hoping the printer company will know something that we don't. This is a very strange issue. If I hear from them or get the problem reolved I will post the response.


Thanks for your help,
-Brian
Andrew  
#7 Posted : Thursday, January 13, 2005 11:16:00 PM(UTC)
Andrew

Rank: Advanced Member

Groups: Member, Administration
Joined: 8/2/2003(UTC)
Posts: 866

Thanks: 2 times
Was thanked: 26 time(s) in 26 post(s)

One last question. If I use the Printer.PaintPicture will that output to the printer in the same resolution and detail as DrawonHDC? I only ask because you said that PaintPicture does some scaling and I didn't know if aurigma was outputing with a higher quality?


Does PaintPicture produce the bad quality?


I'm hoping the printer company will know something that we don't. This is a very strange issue. If I hear from them or get the problem reolved I will post the response.


That would be great.
Gadget  
#8 Posted : Monday, November 14, 2005 5:12:48 AM(UTC)
Gadget

Rank: Member

Groups: Member
Joined: 8/30/2005(UTC)
Posts: 5

Brian,
I am sure that you have already found a solution 1 year later haha. I just posted the following elsewhere because i was having problems with the printer.hdc. I ended up using the form1.printform method that works great.

I have been having so much trouble with printing a simple image on a sheet of paper in a specific location, my hair is falling out. I searched here and found that many were having printing issues as well. I tried many of the solutions and still continued to have problems. Then I fell upon an awsome discovery. Here was my problem.
(VB 6.0)

1. The page size that i needed to use was 9.5" X 7.125" which as you can see is a custom size
2. I needed to print 2 images in a specific location landscape.
3. It was no problem setting my printer to handle the custom size and it appeared to be simple.
4. I made a form the same size as my printer.object width,height,scalewidth,scaleheight and made sure that it was the same scalemode.
5. I put 2 picture boxes on the form. positioned them and removed the border and called the form.printform method.
6. It worked great but i had forgotten to make the form a white background.
7. When I made the form1.background white, and printed it (printform) the pictures moved all the way to the left side of the page. No matter what x,y coords i gave it, it continued to print far left. When I made the form.back grey again, it worked fine. I fought with this for a couple days and came up with no solution.

Today i discovered the solution by accident. Instead of using the picture control, I tried the image control and it worked great even with the form.back white. The only reason I can figure is that, as you probably know the image control has no Hdc property where the Picture control does.

So if you are having problems printing a picture on a form in a specific location, try loading the image into an image control, placing it on the form using the move method, removing the border and then printing using the printform method

Here is some code i use for moving the image around on the screen with the arrow keys before i call printform

Code:
                    'The forms key preview is set to true
                    'chng is a text box to enter the increments to move
                    'x1 is a textbox for the x coords for pic 1
                    'y1 is a textbox for the y coords for pic 1
                    ' remember to make all the controls invisible before calling printform
                    INC = CLng(chng) ' the incremants in the change
                    Select Case KeyCode
                    Case 37 ' move it left
                            X1 = CInt(X1) - INC: DoEvents
                            prntfrm.Cls
                            DoEvents
                            'prntfrm.PaintPicture Clipboard.GetData, CInt(X1), CInt(Y1) 
                            'The above can be used if the image is in the clipboard remember form1.cls after a change
                            pic.Move X1, Y1
                    Case 40 ' movce it down
                            Y1 = CInt(Y1) + INC: DoEvents
                            prntfrm.Cls
                            DoEvents
                            'prntfrm.PaintPicture Clipboard.GetData, CInt(X1), CInt(Y1)
                            pic.Move X1, Y1
                    Case 38 ' move it up
                            Y1 = CInt(Y1) - INC: DoEvents
                            prntfrm.Cls
                            DoEvents
                            'prntfrm.PaintPicture Clipboard.GetData, CInt(X1), CInt(Y1)
                            pic.Move X1, Y1
                    Case 39 'move it down
                            X1 = CInt(X1) + INC: DoEvents
                            prntfrm.Cls
                            DoEvents
                            'prntfrm.PaintPicture Clipboard.GetData, CInt(X1), CInt(Y1)
                            pic.Move X1, Y1
                    
                    End Select


I then save the coords in the win registry so that they are there the next time the program runs without re-designating them.

Code:
SaveSetting "PhotoProcessor", "Coords", "pic1x", X1.Text
SaveSetting "PhotoProcessor", "Coords", "pic1y", Y1.Text
SaveSetting "PhotoProcessor", "Coords", "pic2x", X2.Text
SaveSetting "PhotoProcessor", "Coords", "pic2y", Y2.Text



I hope this help someone..
Ira
iwhitney@iwdata.com


printing images,printer,printform,printer.hdc

Edited by user Sunday, December 23, 2007 4:55:07 PM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.