忍者ブログ
[410]  [409]  [408]  [407]  [406]  [405]  [404]  [403]  [402]  [401]  [400
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

gdi+ で汎用エラーが発生しました

出たりだ無かったり

1.vbでPictureBoxにファイルを読み込む
                Dim fs As System.IO.FileStream
                fs = New System.IO.FileStream(filename _
                      , System.IO.FileMode.Open _
                       , System.IO.FileAccess.Read)
                Try
                    PictureBox1.Image = System.Drawing.Image.FromStream(fs)
                Catch argEx As ArgumentException
                    MsgBox(argEx.Message, MsgBoxStyle.Information)
                End Try
                fs.Close()
2.またはクリップボードからはり付けで

 PictureBox1.Imageを書き込むと
gdi+ で汎用エラーが発生しましたが発生する

原因は、どうもPictureBox1にロックがかかるみたい、、、、

で対応は
一端bitmapに読み込んで出力
            Dim bmp As Bitmap = New Bitmap(PictureBox1.Image)
            Dim fs As System.IO.FileStream = New IO.FileStream(fname, IO.FileMode.Create)
            bmp.Save(fs, Imaging.ImageFormat.Jpeg)
            fs.Close()




拍手

PR
カレンダー
03 2025/04 05
S M T W T F S
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
フリーエリア
最新CM
[03/10 DORA]
最新TB
プロフィール
HN:
dorabu
性別:
非公開
バーコード
ブログ内検索
P R
Copyright © ドラブーのアンドロイドとIoTなブログ All rights reserved. / Template by 四季. / Material by てんせん.

忍者ブログ [PR]