pythonwin in memory device context

Ilariu Raducan lale at fotonation.com
Thu May 1 10:16:00 EDT 2003


Can you tell me what is wrong with this code:

         im = Image.open('DCP_4811.JPG')
         self.size=im.size
         self.dib = ImageWin.Dib("RGB",im.size)

     def OnDraw(self,dc):
         dst=self.GetClientRect()
	self.dib.draw(dc.GetHandleAttrib(),dst, 	   (0,0,self.size[0],self.size[1])

I get a black display. It seems to have the right size.
When I scroll I can see that


Thank you,
Lale






Fredrik Lundh wrote:
> Ilariu Raducan wrote:
> 
> 
>>Does anybody has an example how to use a memory device context?
>>Let me explain what I want to do:
>>
>>Load an image with PIL.Image
>>create a ImageWin.Dib object
>>paste the image in dib
> 
> 
> at this point, PIL has created a memory DC for you.
> 
> 
>>Then for each OnDraw
>>
>>use StretchBlt to paint a part/all image on the client window
> 
> 
> I didn't mention it in my earlier post, but PIL's "draw" method
> takes an optional third argument:
> 
>     dib.draw(dc, destination_rectangle, source_rectangle)
> 
> the default source is the entire image.
> 
> </F>
> 
> 
> 
> 





More information about the Python-list mailing list