Hello all:
I am looking the sample code posted on PIL website http://www.pythonware.com/library/pi.../imagedraw.htm
############### ############### ############### ###
<<Draw a Grey Cross Over an Image>>
import Image, ImageDraw
im = Image.open("len a.pgm")
draw = ImageDraw.Draw( im)
draw.line((0, 0) + im.size, fill=128)
draw.line((0, im.size[1], im.size[0], 0), fill=128)
del draw # ===>>>Why we should delete this object draw?
# write to stdout
im.save(sys.std out, "PNG")
############### ############### ############### ####
Is there any general rule that we must delete the object after using
it?
Thank you
-Daniel 3 6485
Daniel Mark wrote:
Hello all:
I am looking the sample code posted on PIL website http://www.pythonware.com/library/pi.../imagedraw.htm
############### ############### ############### ###
<<Draw a Grey Cross Over an Image>>
import Image, ImageDraw
im = Image.open("len a.pgm")
draw = ImageDraw.Draw( im)
draw.line((0, 0) + im.size, fill=128)
draw.line((0, im.size[1], im.size[0], 0), fill=128)
del draw # ===>>>Why we should delete this object draw?
# write to stdout
im.save(sys.std out, "PNG")
############### ############### ############### ####
Is there any general rule that we must delete the object after using
it?
Just consider it good hygiene.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
Steve Holden wrote:
>Is there any general rule that we must delete the object after using it?
Just consider it good hygiene.
in this specific case, it may not be obvious for the casual reader that
the global "draw" variable will contain an indirect reference to the
original image object, so even if you throw away (or replace) the "im"
variable with something else, the original image will still be present
in memory.
if you put the same code inside a function, you can safely leave the
garbage handling to Python.
</F> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alex Vinokur |
last post by:
http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.6
Faq-20.6 contains function userCode(Shape&) :
void userCode(Shape& s)
{
Shape* s2 = s.clone();
Shape* s3 = s.create();
...
// stuff; for instance
|
by: tvmaly |
last post by:
I have been trying to add a watermark to a jpeg using PIL, but the
watermark has a black box around it. I looked at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/362879
and
http://mail.python.org/pipermail/python-list/1999-May/003369.html
but I think these only refer to gif or png. I know jpegs really do not
|
by: qvx |
last post by:
Hi all,
I have a performance problem in my app. It is a poor man's version of
OCR app. I started this app as a prototype before implementing it in
C++. But now, after I have a working copy in Python, I don't feel like
doing the job again in C++. A speed improvement of at least 5 times
would be necessary (I have to process several hundreds of thousands of
images).
The application works like this:
|
by: Tobias Froehlich |
last post by:
Hello,
I'd like to create a drawing field on a form in which I can draw
(using the Pen class I guess). I've found tutorials on how to use the
GDI+ but I still haven't found out how to actually create a BOX (with
a specified size) in which the user can draw (he shouldn't be able to
draw on the whole form / window!). I will also need to be able to get
information on the drawn pixels in that box (specifically: i need to
draw a rectangular...
|
by: VB Programmer |
last post by:
I created a VB.NET user control which I now want to use in my ASP.NET
webform. The uc shows up fine in my toolbar, but when I click on it it goes
to the bottom of the form, rather than letting me 'draw' it. (Kind of like
what happens when you place a Timer control on a form, rather than a Text
Box control.)
Ideas?
Thanks!
| |
by: Microsoft |
last post by:
When I try this in my code I alwas get an errormessage: "Object reference
not set to an instance of an object"
Dim g As System.Drawing.Graphics
g.DrawString("Test", New Font("Arial", 12, FontStyle.Bold), Brushes.Black,
0, 0)
Why is this?
Marc
|
by: gw7rib |
last post by:
I've been bitten twice now by the same bug, and so I thought I would
draw it to people's attention to try to save others the problems I've
had. The bug arises when you copy code from a destructor to use
elsewhere.
For example, suppose you have a class Note. This class stores some
text, as a linked list of lines of text. The destructor runs as
follows:
Note::~Note() {
|
by: jk2l |
last post by:
Error 10 error LNK2019: unresolved external symbol __imp__glBindTexture@8 referenced in function "public: void __thiscall GLTexture::Use(void)" (?Use@GLTexture@@QAEXXZ) GLTexture.obj
Error 11 error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function "public: void __thiscall GLTexture::Use(void)" (?Use@GLTexture@@QAEXXZ) GLTexture.obj
Error 12 error LNK2001: unresolved external symbol __imp__glEnable@4 Model_3DS.obj ...
|
by: ValValVal |
last post by:
Hi all.
I am creating a chess game and now I need draw pieces on board.
Creating every shape using GeneralPath and curves that are part of Graphics2D is difficult, especially when I draw a knight,because I must play endlessly with curves to see how they look.
So probably better decision is to create gif or jpg files that include images of pieces.
But images in files are square and I don't need to draw all the square ,I only need to draw...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |