RawImage.Data and Scanline bug in TPicture.Bitmap [Lazarus]
Loads JPEG / PNG / GIF files etc. other than BMP format in TPicture.If you use RawImage.Data, Scanline in TPicture.Bitmap as it is, the image will be distorted.
TPictureでBMP形式以外のJPEG/PNG/GIFファイルなどを読み込みます。そのままTPicture.BitmapでRawImage.Data、Scanlineを使用すると画像が乱れます。(横線やグレースケールなどになる)
Version (バージョン)
Lazarus 1.8.2 (Windows)
Lazarus 1.8.4 (Windows)
Workaround (回避方法)
Draw the image of TPicture.Bitmap on another TBitmap with StretchDraw. And, using that TBitmap is ok.
TPicture.Bitmapの画像をStretchDrawで別のTBitmapに描画します。そして、そのTBitmapを使用すればOKです。
procedure Image2Bitmap(var src:TBitmap); var bmp : TBitmap; begin bmp := TBitmap.create; try bmp.PixelFormat:= pf24bit; bmp.Width := src.width; bmp.height := src.height; bmp.Canvas.Brush.Color:= clWhite; bmp.Canvas.FillRect(0,0,src.width,src.height); bmp.Canvas.StretchDraw(Rect(0,0,src.width,src.height),src); src.Assign(bmp); finally bmp.free; end; end; --- bmp := TBitmap.create; try bmp.Assign(Image1.Picture.Bitmap); Image2Bitmap(bmp); // use this bmp (このbmpを使用する) bmp finally bmp.free; end;
I used time, but I hope it will be helpful for someone. :-)
時間を使ってしまいましたが、どなたかの参考になると幸いです。
関連記事
前の記事: | LazarusでMySQLにアクセスする |
この記事を書いた人
![]() | 💻 ITスキル・経験 サーバー構築からWebアプリケーション開発。IoTをはじめとする電子工作、ロボット、人工知能やスマホ/OSアプリまで分野問わず経験。 画像処理/音声処理/アニメーション、3Dゲーム、会計ソフト、PDF作成/編集、逆アセンブラ、EXE/DLLファイルの書き換えなどのアプリを公開。詳しくは自己紹介へ |
プチモンテ代表、アーティスト名:プチモンテ | |
🎵 音楽制作 BGMは楽器(音源)さえあれば、何でも制作可能。歌モノは主にロック、バラード、ポップスを制作。歌詞は叙情詩、叙情的な楽曲が多い。楽曲制作は2023年12月中旬 ~ |
オリジナル曲を始めました✨
YouTubeで各楽曲を公開しています🌈
https://www.youtube.com/@petitmonte