Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PictureBox saving blank .bmp

Status
Not open for further replies.

btt423

Programmer
Jan 28, 2002
31
US
I'm developing an ActiveX dll that generates a barcode (using an activex control) and saves a .wmf of the barcode. The .wmf file saves without a problem. I then load the .wmf file into a PictureBox control. I am then using that picturebox to paint a portion of the loaded .wmf file into a second picturebox using PaintPicture. The second picturebox then saves the image as a .bmp to the hard drive. All of this is done behind the scenes on a hidden form. I had this working for about 8 or 9 months, and it recently stopped working, and I've been banging my head against a wall for 3 straight days. The problem is that the bmp that is saved is blank. It comes out the exact size it is supposed to, but it shows up blank.

If i run this inside VB, it runs fine. When I compile into a dll and instantiate in an asp file, no errors are thrown, but the bmp is blank. The thing that really stumps me is it worked for quite a while without a problem. I've tried reloading the server, I've tried other machines and I'm just drawing a blank as to what to try next.

Any help would be greatly appreciated. Here is my code:

Code:
Private Sub doBarcode(strText As String, intNum As Integer)
    Dim strFileName As String
    Dim strBMPPath As String
    Dim strWMFPath As String
    Dim intImageID As Integer
    Dim PX1 As Single
    Dim PX2 As Single
    Dim PY1 As Single
    Dim PY2 As Single
    
    strWMFPath = "c:\UPMISAPP\wmf\"
    strBMPPath = "c:\UPMISAPP\bmp\"
    
    
    WriteToLog "WMFPath = " & strWMFPath & ", BMPPath = " & strBMPPath
    ' Setup the barcode object
    strFileName = intNum
    frmBarCode.bc.AutoSize = False
    frmBarCode.bc.SymbologyID = CODE39
    frmBarCode.bc.Wide2NarrowRatio = 3
    frmBarCode.bc.NarrowBarWidth = 0.06
    frmBarCode.bc.BarHeight = 0.5
    frmBarCode.bc.DataToEncode = strText
    frmBarCode.bc.SaveEnhWMF strWMFPath & strFileName & ".wmf"
    frmBarCode.bc.Width = frmBarCode.bc.GetXPixels * 17
    frmBarCode.bc.Height = 425
    WriteToLog "Barcode generated"
    
    frmBarCode.picBarcode2.Cls
    frmBarCode.picBarcode.Picture = LoadPicture(strWMFPath & strFileName & ".wmf")
    frmBarCode.picBarcode.ScaleMode = vbTwips
    frmBarCode.picBarcode2.ScaleMode = vbTwips
    WriteToLog "Loaded WMF file"
    
    PX1 = 0
    PX2 = frmBarCode.picBarcode.Width
    PY1 = 0
    PY2 = 395
    WriteToLog "PX1 = " & PX1 & ", PX2 = " & PX2
    
    frmBarCode.picBarcode2.Width = PX2
    frmBarCode.picBarcode2.Height = PY2
    frmBarCode.picBarcode2.PaintPicture frmBarCode.picBarcode.Image, 0, 0, PX2, PY2, PX1 + 65, PY1 + 65, PX2, PY2
    WriteToLog "Loaded image to second picturebox"
    frmBarCode.picBarcode2.Picture = frmBarCode.picBarcode2.Image
    
    SavePicture frmBarCode.picBarcode2.Picture, strBMPPath & strFileName & ".bmp"
    WriteToLog "Saved picture"
    
    'intImageID = m_txc.ObjectInsertAsChar(0, strBMPPath & strFileName & ".bmp", -1, 100, 100, 0, 1)
    'WriteToLog "Barcode image id: " & intImageID
    
    'm_intBarcodeCount = m_intBarcodeCount + 1
End Sub

Thanks!
 

Try ...
[tt]
SavePicture frmBarCode.picBarcode2.Image, strBMPPath & strFileName & ".bmp"
[/tt]

Just a though

Good Luck

 
vb5prgrmr, thanks for the reply. I tried that at one point and it did not work. I was able to figure the problem out though. The server had been upgraded to Win2000 sp4. SP4 and SP2 have a problem that SP3 fixes. I just rolled back the sp and it worked fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top