How to define a bitmap object in delphi, associate it with a window context, and draw a bitmap? Give pzhl as an example the minimum code.
2 answers
Put the TImage component (with the name image) on the form. Then at any convenient time we do:
// Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ Π±ΠΈΡΠΌΠ°Ρ b := TBitMap.create; // ΠΠ°Π΄Π°Π΅ΠΌ ΡΠ°Π·ΠΌΠ΅ΡΡ BitMap, ΡΠ°Π²Π½ΡΠ΅ ΡΠ°Π·ΠΌΠ΅ΡΠ°ΠΌ image b.Height:=image.Height; b.Width:=image.Width; // TODO: Π ΠΈΡΡΠ΅ΠΌ Π½Π° Π±ΠΈΡΠΌΠ°ΠΏΠ΅ ΠΈΠ»ΠΈ Π·Π°Π³ΡΡΠΆΠ°Π΅ΠΌ ΠΊΠ°ΡΡΠΈΠ½ΠΊΡ ΠΈΠ· ΡΠ°ΠΉΠ»Π° // ... // ΠΠΎΠΊΠ°Π·ΡΠ²Π°Π΅ΠΌ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ Π½Π° ΡΠΊΡΠ°Π½Π΅ image.Picture.Assign(b); // ΠΡΠΈΡΠ°Π΅ΠΌ ΠΏΠ°ΠΌΡΡΡ b.Free;
- You just misunderstood the question =) - AseN
|
An example of how to draw on the desktop:
var bmp:Tbitmap; begin bmp:=Tbitmap.Create; bmp.canvas.Handle:=getdc(0); //ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΠΊΠΎΠ½ΡΠ΅ΠΊΡΡ(HDC) ΡΠ°Π±ΠΎΡΠ΅Π³ΠΎ ΡΡΠΎΠ»Π° bmp.canvas.Rectangle(0,0,200,100); // Π Π΄Π°Π»Π΅Π΅ ΡΠΈΡΡΠ΅ΠΌ, ΠΊΠ°ΠΊ Π² ΠΎΠ±ΡΡΠ½ΠΎΠΌ TbitMap`Π΅ =)
|