?
Solved

How can I access a Timage form a Tread safely?

Posted on 2009-04-04
3
Medium Priority
?
445 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 1500 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

Industry Leaders: 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

800 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