Problems with CFbsbitmap->getPixel()

Login to reply to this topic.
Tue, 2008-07-01 11:45
Joined: 2008-07-01
Forum posts: 4

Hi all,
I have a problem with the getPixel function from CFbsBitmap: In a single-thread program it works fine but if I try to call it from a new thread it does no longer work, the program crashes. Interestingly the SizeInPixels function works for both.
Does anyone know what the problem could be?
Many Thanks
Marcel


Tue, 2008-07-01 12:18
Joined: 2004-11-29
Forum posts: 1155
Re: Problems with CFbsbitmap->getPixel()

The CFbsBitmap handle is local for the thread where you create it.

If you want to use it in another thread, you have to create a new CFbsBitmap object in that thread, and send over the Handle() of the bitmap and use Duplicate() to use it from the new thread.

The reason SizeInPixels works is because that specific information is cached client side, so it doesn't have to ask the Font&Bitmap server for it.

Tue, 2008-07-01 12:25
Joined: 2004-11-29
Forum posts: 1155
Re: Problems with CFbsbitmap->getPixel()

ofcourse, if the two threads are from the same process, you can call Handle() also from within the new thread, to get the handle, and duplicate it.

This might look funny, and might make you ask why you need it... The reason is that the session to the Font&Bitmap server is a kernel object, and those are owned by the thread, so you have to recreate it in the new thread.

If the threads are in different processes, then you really have to send over just the handle somehow.

Tue, 2008-07-01 13:36
Joined: 2008-07-01
Forum posts: 4
Re: Problems with CFbsbitmap->getPixel()

Hi alh,
thanks for your answer, now it works but one important thing to remember is the line
User::LeaveIfError(RFbsSession::Connect());
Without this it didn't work

  • Login to reply to this topic.