Solved

How can I access a Timage form a Tread safely?

Posted on 2009-04-04
3
444 Views
Last Modified: 2013-11-22
I have encountered a problem using VCL and Threads. I know Syncronize is must be used to access the components on the form (like SpinEdit etc) but how can I access an Image safely from a thread?  

(i have "Invalid pointer" errors randomly and this makes me feel the Image access can be the problem. )

Thank you
0
Comment
Question by:verjoz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 21

Expert Comment

by:developmentguru
ID: 24068690
 Normally you do not access the visual controls directly from the thread.  You set up synchronized events that the thread can fire.  From the response event within the form's code you then do what you need to, using the form's controls.

  One other thing to be careful of is the fact that some on screen controls use their own thread.  Trying to update such a control from within a synchronized call from another thread can cause problems.  Normally in this situation I make it easy on myself and use a simpler control.

  If you need more help it would help to know more about what you are trying to accomplish.
0
 

Author Comment

by:verjoz
ID: 24070885
Thank you for your response. I have to draw a picture coming from a USB camera to the Timage. So the steps:
- I get a buffer of the actual camera picture in (RGB format) in the thread
- I update it to the image1.picture.bitmap using the scanline pixel by pixel in the thread
- and finially I use the Image1.Refresh to appear the actual frame in the thread

How else can I solve it? And is it thread safe?

0
 
LVL 21

Accepted Solution

by:
developmentguru earned 500 total points
ID: 24072267
I would use the thread to translate the image to a TBitmap (within the thread).  When the translation is completed I would fire an event (within syncronize of course) passing the bitmap.  You can then assign the bitmap to the Image.Picture.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question