pythonwin in memory device context

Ilariu Raducan lale at fotonation.com
Thu May 1 12:10:33 EDT 2003


Hmm.. I forgot to use dib.paste
Now it works, sort of..

If source and destination have the same size, it looks good
If destination is smaller then the source, it loose some of the colors.
It looks like an image with saturated colors.

Regards,
Lale

Ilariu Raducan wrote:
> 
> 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