閑古鳥

オールドプログラマの日記。プログラミングとか病気(透析)の話とか。

Polyline で憤死

高々 5 万点程度のデータを Polyline 使って線を描くと処理が戻ってこなくなります。ペンの幅が 1 ピクセルなら問題ないのですが、 2 ピクセル以上になるともう駄目。

調べても何も出てこないし Polyline 自体のドキュメント (MSDN) にもなにも書いてない。国内には情報無いのかなあ、と思い、なんとなく Polyline の英語の方の解説を見たら以下のような記述が。

Windows 95/98/Me: Polyline cannot draw more than a certain number of points. The limit depends on the line width (that is, the width of the pen selected into the DC), as shown in the following table.

Line width Maximum points allowed
line width is 1 16K
line width > 1 (that is, wideline) and device supports wideline 16K
line width > 1 but device does not support wideline approximately 1360 (that is, approximately 16K / 12)

Any extra points are ignored. To draw a line with more points, divide the data into groups that have less than the maximum number of points and call the function for each group of points. Remember to connect the line segments.

うーん、しかし、 OS は XP なのでこの制約は関係ないはず。 XP でも line width > 1 が成り立つ場合は 16000 点以下に抑えておいた方が良いということなのだろうか?

もう少し調べてみるか……。というか、こういうのもちゃんと訳しておいてよね!