← 戻る

記事閲覧

この記事に返信する
投稿キー
右の画像の数字を入力 投稿キー
英数字で8文字以内
文字色 ■ ■ ■ ■ ■ ■ ■ ■ ■
コンビニ用バーコード作成時の速度改善について 投稿者:hiro 2011/11/30(Wed) 18:51 No.1266
製品版Ver. 2.3.0.0を、.NET 1.1 にて使用しております。
下記の関数にてコンビニ用バーコードを一括作成しておりますが、大量に作成した場合に処理速度が落ちます。
300件作成時、600件/分。1500件作成時、56件/分。
PCの処理速度の問題もあるかと思いますが、改善する方法はないでしょうか。

Public Shared Sub DrawBarCode(ByVal KCs As ArrayList, ByVal sFilePath As String, ByVal SEI_Y As String)

Dim bmp As New Bitmap(700, 220)
bmp.SetResolution(300, 300)

Dim g As Graphics = Graphics.FromImage(bmp)
g.PageUnit = GraphicsUnit.Display
g.FillRectangle(New SolidBrush(Color.White), 0, 0, bmp.Width, bmp.Height)

Dim code As String = String.Empty
Dim ean128 As Pao.BarCode.EAN128

Try
ean128 = New Pao.BarCode.EAN128(g)
ean128.RotateAngle = angle
ean128.TextWrite = True
ean128.TextKintou = False
ean128.KuroBarChousei = 0
ean128.ShiroBarChousei = 0
ean128.TextFont = New Font("MS ゴシック", 8)

For Each KC As String In KCs
code = "{FNC1}9100000000000000000" & KC & "00000000005000"

ean128.DrawConvenience(code, 0, 0, 11)

bmp.Save(sFilePath, Imaging.ImageFormat.Gif) 'sFilePathのパスにKCのファイル名で保存

g.Clear(Color.White)
Next

Catch ex As Exception
Throw ex
Finally
bmp = Nothing
g = Nothing
ean128 = Nothing
End Try

End Sub
Re: コンビニ用バーコード作成時の速度改善について 投稿者:Pao@Office 2011/12/01(Thu) 15:43 No.1267
お問い合わせありがとうございます。
大量コンビニバーコード描画時、描画速度が遅くなる件につきましては、少しお時間をください。
同じプログラムを作成し、
「どの箇所でどのようにメモリなどのリソースをリークしていくのか?」
調査をさせていただきます。
調査に10日程度お時間をください。
よろしくお願いいたします。
Re: コンビニ用バーコード作成時の速度改善について 投稿者:Pao@Office 2011/12/02(Fri) 20:51 No.1268
hiro様のプログラムに一部手を加えさせていただき
実測させていただきました。
PCスペック:Core2 / Mem 4GB
結果、コンビニバーコード1500件で描画で30秒弱しかかかりませんでした。
再現できていない理由は未だわかりませんが、他に原因があるかもしれません。
こちらに手違いがございましたら申し訳ございません。
メールの方でも返信させていただきます。
よろしくお願いいたします。

--Debug.Print の結果---
Start: 08:12:07
End: 08:12:31
-----------------------


-- 以下プログラム ---
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click

Dim arr As ArrayList = New ArrayList

Dim i As Integer
For i = 1 To 1500
arr.Add(i.ToString())

Next

DrawBarCode(arr, "./aaa.bmp", "aaa")

End Sub

Public Shared Sub DrawBarCode(ByVal KCs As ArrayList, ByVal sFilePath As String, ByVal SEI_Y As String)

Dim bmp As New Bitmap(700, 220)
bmp.SetResolution(300, 300)

Dim g As Graphics = Graphics.FromImage(bmp)
g.PageUnit = GraphicsUnit.Display
g.FillRectangle(New SolidBrush(Color.White), 0, 0, bmp.Width, bmp.Height)

Dim code As String = String.Empty
Dim ean128 As Pao.BarCode.EAN128

Try
ean128 = New Pao.BarCode.EAN128(g)
'ean128.RotateAngle = angle
ean128.TextWrite = True
ean128.TextKintou = False
ean128.KuroBarChousei = 0
ean128.ShiroBarChousei = 0
ean128.TextFont = New Font("MS ゴシック", 8)

Debug.Print("Start: " & DateTime.Now.ToString("hh:MM:ss"))

For Each KC As String In KCs
code = "{FNC1}91912345000000000000004520875004013100295006"

ean128.DrawConvenience(code, 0, 0, 11)

bmp.Save(sFilePath, Imaging.ImageFormat.Gif) 'sFilePathのパスにKCのファイル名で保存

g.Clear(Color.White)
Next

Debug.Print("End: " & DateTime.Now.ToString("hh:MM:ss"))

Catch ex As Exception
Throw ex
Finally
bmp = Nothing
g = Nothing
ean128 = Nothing
End Try

End Sub
Re: コンビニ用バーコード作成時の速度改善について 投稿者:hiro 2011/12/18(Sun) 19:03 No.1275
投稿者のhiroです。

いただいたサンプルをいくつかの環境で動かしたところ、英語版OSでは正常に動作しました。
ただし、直接の原因では無いと思われますので、FrameworkのVERUPなど別の方法を検討いたします。

ありがとうございました。
453541 投稿者:www.allcatholicjewelry.com 2015/09/16(Wed) 01:32 No.1382
2010 Shoes Trend
126164 投稿者:Cartier Jewelry Replica 2015/09/17(Thu) 07:04 No.1392
Until I went to junior high with his father from rural to city of reading, then comes the beginning of the Reformation, electronic hawkers from the South to the North, some students wore a show off in front of me, I also want to have a piece of my own spreadsheet, but I did not ask his father for always, know it is difficult. Makes me believe to be that one day his father suddenly pulled out from his pocket a spreadsheet of my dreams, let me surprise, knew that his father knew my thoughts. I treasured up, timekeeping, calendars automatically adjust quickly, wears well and as good as new for a long time, until the battery runs out only 10,000 are not prepared to put in the closet store.

- YY-BOARD -