Guidance
指路人
g.yi.org
Guidance Forums / Rapid-Q Basic / erm ..... but WHY doesn't it work ?

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. erm ..... but WHY doesn't it work ?
#1076
Posted by: 2003-08-14 00:30:29
I want to display a small bitmap on a QCanvas and to have said bitmap in the EXE file. This is the sourcecode;

$RESOURCE bl1 as "test.bmp"

dim form as qform
  form.width = 300
  form.height = 300
  form.center
  form.caption =  " Diona's eye"

Dim Image AS QCanvas
  Image.Height = 200
  Image.Width = 200
  Image.Left = 4
  Image.Top = 4
  Image.OnPaint = Image.Paint
  Image.Parent = Form

Form.ShowModal

SUB Image.Paint
 Image.rectangle (9,9,79,48,&hFFFFFF)
 Image.draw (10,10,bl1)
 Image.rectangle (0,0,200,200,&hFFFFFF)
END SUB


I don't understand WHY it doesn't show the attached pic on the canvas (it should fit inside the smaller rectangle). Please explain what I am doing wrong ?

Message2. Re: erm ..... but WHY doesn't it work ?
#1077
Posted by: 2003-08-14 03:52:17
You need to have the .bmp property in the draw method. For this you must define either a QBitmap ro a QImage.
Here's what you need to write - (Using $resource, as you have done, integrates test.bmp into the executable file - you can shorten the program a bit by defining 'bl1.BMP = "test.bmp"', and removing the '$resource' and the 'bl1.BMPhandle' lines, but this means you have to distribute the bitmap with the executable as a separate file  --- It's up to you.)
 $RESOURCE bl2 AS "test.bmp"

 DIM bl1 AS QIMAGE
 bl1.BMPhandle = bl2

 DIM form AS QFORM
 form.width = 300
 form.height = 300
 form.center
 form.CAPTION = " Diona's eye"

 DIM Image AS QCANVAS
 Image.Height = 200
 Image.Width = 200
 Image.Left = 4
 Image.Top = 4
 Image.OnPaint = Image.Paint
 Image.PARENT = Form

 Form.SHOWMODAL

 SUB Image.Paint
  Image.rectangle (9,9,79,48,&hFFFFFF)
  Image.draw (10,10,bl1.BMP)
  Image.rectangle (0,0,200,200,&hFFFFFF)
 END SUB
Message3. Re: erm ..... but WHY doesn't it work ?
#1078
Posted by: Ad 2003-08-14 14:13:05
Great, thanks Dav :)

A while back I posted a game I was working on (Diona's game), matter of fact I am still working on it. The new version uses graphics for the blocks, has a tutorial mode ..... etcetera. I will upload the final EXE rather than the sourcecode when it is finished because

 a.) I don't want anyone to mess with it

 b.) there are several images (and that's why I am using $Resource in it)

 c.) I don't want people to cheat at the game (it has highscore encoding built in etcetera)

See the attached picture :) that is how the game starts (except for the green comment bit obviously)



Post Edited (08-14-03 14:16)
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
¥1,280.00 ·
 
 
¥810.00 ·
 
 
¥1,580.00 ·
 
 
¥487.00 ·
 
 
¥490.00 ·
 
 
¥1,480.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0