简体   繁体   English

ZXing条码编写器析构函数

[英]ZXing Barcode Writer Destructor

I am attempting to write a program with ZXing which continually scans keyboard input, converting the input into a QR code. 我正在尝试使用ZXing编写程序,该程序会不断扫描键盘输入,并将输入转换为QR码。 This QR code is then read by using the BarcodeReader Class. 然后使用BarcodeReader类读取此QR码。 The BarcodeReader keeps the resources for this file, even after the subroutine that contains the object has completed. 即使包含对象的子例程已完成,BarcodeReader仍保留该文件的资源。 This prevents me from being able to save a new QR Code which overwrites the existing QR Code because it is still in use! 这使我无法保存新的QR码,因为它仍在使用中,它会覆盖现有的QR码! To solve this problem I attempted to invoke the destructor for the class, but there is none I can find. 为了解决此问题,我尝试为该类调用析构函数,但找不到任何析构函数。 Any help on this issue would be greatly appreciated.The code below is where the destructor should be called. 在这个问题上的任何帮助将不胜感激。下面的代码是应该调用析构函数的地方。

'Read any 2D Barcode, this will only ever be a QR code for this project
 Private Function read2D(location As String)
    Dim reader = New ZXing.BarcodeReader()
    Try
        Dim result = reader.Decode(Bitmap.FromFile(location))
        Return "Succesfully Read 2D Barcode:" + result.ToString
    Catch ex As Exception
        Return "Error Reading 2D Barcode"
    End Try
End Function

It's not the BarcodeReader who holds the lock. 持有锁的不是BarcodeReader。 You have to dispose the bitmap instance which you get from Bitmap.FromFile. 您必须处理从Bitmap.FromFile获取的位图实例。 https://msdn.microsoft.com/en-us/library/4sahykhd(v=vs.110).aspx https://msdn.microsoft.com/zh-CN/library/4sahykhd(v=vs.110).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM