| 
     
      
      
      From: Mauro C. <mau...@ep...> - 2005-11-30 09:48:59
      
     
   | 
Thanks Alex for the quick answer!
Actually, when I say existing bitmap I mean an external png file that =20=
represent a geographical map.
What I want to do is to add to this map some "dots" and "lines" at =20
specific locations according to some logic I have in the rest of the =20
program.
I did this using PIL, editing the existing bitmap and saving the =20
results into a new file. I was hoping to do the same with PythonCard, =20=
maybe working on a transparent canvas which should overlay the =20
existing bitmap. But I cannot figure out the way to do it.
At the moment I have two components in the resource file. The Image =20
component gets loaded on top of the BitmapCanvas, of which shares the =20=
same dimensions and position:
{'type':'BitmapCanvas',
     'name':'Canvas',
     'position':(200, 0),
     'size':(800, 600),
#    'backgroundColor':(255, 255, 255),
     },
{'type':'Image',
     'name':'canvasBackground',
     'position':(200, 0),
     'file':'campus_base.png',
     },
The program file contains a piece of drawing code that should be =20
activated when pressing a certain button:
    def bitmapCanvasTest(self):
         canvas =3D self.components.Canvas
         canvas.drawPoint((5, 5))
         canvas.foregroundColor =3D 'red'
         canvas.drawLine((5, 10), (20, 30))
         canvas.foregroundColor =3D 'blue'
         canvas.drawRectangle((25, 5), (30, 20))
         canvas.drawText('Text', (5, 30))
         canvas.drawRotatedText('Rotated', (60, 40), 90)
         canvas.foregroundColor =3D 'gray'
         canvas.fillColor =3D 'gray'
         canvas.drawEllipse((80, 5), (30, 30))
The problem is than when called, these commands change the ordering =20
of the canvases, bringing the BitmapCanvas on top of the Image that =20
stays as background, with subsequent loss of the reference points =20
(aka, I cannot see the background any more).
Now, what I was trying to do was to either: 1) make the BitmapCanvas =20
background transparent or either drawing directly on the png file =20
image that is loaded on the background. So far, I have not figured =20
out the right syntax to do that or/and if it is the right way to do it.
Thanks again in advance for any kind soul that wants to join this =20
discussion
Mauro
On Nov 29, 2005, at 19:20 , Alex Tweedly wrote:
> Mauro Cherubini wrote:
>
>> Dear All,
>>
>> sorry for the newbie question but I am fighting with the =20
>> following  issue:
>> I am trying to add some drawing on top of an existing bitmap.
>
> When you say "existing bitmap" do you mean an existing bitmapCanvas =20=
> component ?
>
>> I tried two things: the first one was to draw directly on the =20
>> image  setting that as the working canvas (i.e., canvas =3D  =20
>> self.components.canvasBackground); the second was to draw on a  =20
>> separate canvas.
>>
>> The first attempt raised an exception because apparently is not  =20
>> possible to draw on bitmaps.
>
> You should be able to do this. If you didn't already, see the =20
> 'gravity' example in the samples directory (or any of the other =20
> samples that use bitmapCanvas). If you still have a problem with =20
> this, post again maybe including the code that is failing ... (if =20
> you do - please try to give us a complete, small example including =20
> resource file).
>
>> The second attempt load the drawing  canvas on top of the =20
>> "background" bitmap and because it is not  transparent it covers =20
>> automatically the background.
>>
> Don't think you can get transparent bitmapCanvas.
>
>> I tried to set the 'backgroundColor' to 'None' but without =20
>> success  (it says that 'AttributeError: 'BitmapCanvas' object has =20
>> no attribute  'backgroundColour'').
>>
> You may not be able to set it to None - but you can set the =20
> backgroundColor
> (was it a mis-spelling as backgroundColour ??)
>
> I added :
>   self.components.bufOff.backgroundColor =3D (255,255,0)
> to the on_initialize of the gravity example and it worked =20
> beautifully (maybe that's the wrong word for a bright yellow =20
> background :-)
>
> --=20
> Alex Tweedly       http://www.tweedly.net
>
>
>
> --=20
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.362 / Virus Database: 267.13.8/183 - Release Date: =20
> 25/11/2005
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through =20
> log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD =20
> SPLUNK!
> http://ads.osdn.com/?ad_id=3D7637&alloc_id=3D16865&op=3Dclick
> _______________________________________________
> Pythoncard-users mailing list
> Pyt...@li...
> https://lists.sourceforge.net/lists/listinfo/pythoncard-users
_______________
Mauro Cherubini
Research Associate
Centre de Recherche et d'Appui pour la Formation et ses Technologies =20
(CRAFT) / Center for Research and Support of Training and its =20
Technologies
Ecole Polytechnique F=E9d=E9rale de Lausanne (EPFL) / Swiss Federal =20
Institute of Technology Lausanne
Address: CE 1.631 (B=E2timent CE), Station 1, EPFL - Ecublens, CH - =20
1015 Lausanne, Switzerland
T=E9l=E9phone:  +41 (0)21/693.27.05 -- Fax:  +41 (0)21/693.60.70 -- =20
Mobile:  +41 (0)78/ 913.50.11
web: http://craft.epfl.ch -- blog: http://www.i-cherubini.it/mauro/blog/
 |