Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Imagebox picture clears when you put a frame over it. in Win 7

Status
Not open for further replies.

tedsmith

Programmer
Nov 23, 2000
1,762
0
0
AU
I have an imagebox that I feed with a JPG through a winsock connection.(Using Endamo's routines from my previous posts)
(Using Windows7 pro)
When I temporarily put a frame containing a notice over part of it, when I remove the frame, it erases only the part of the picture previously covered by the frame.

This does not happen when I use loadpicture to put a jpg on the imagebox and does not happen when I move a code window over the first picture with the program halted.

I tried Aero on and off and it doesn't make any difference.

What would be happening here? It seems the picture is not "persistent".
 
Let's just clarify first. When you say ImageBox (a non-existant control in VB) do you mean PictureBox control or Image control (the mashup of names you've used means it could be either)?

(and just to be pedantic - Edanmo has no routines. It is a type library)
 
By Imagebox I meant Image Control, yes I know I wrongly used the term 'routines'.

Experimenting further I found that if I move a frame over the image only immediately after it has been received, it is OK in that it reappears after the frame has been removed.
But -
I have 16 small (thumbnail size) image boxes receiving different jpgs. but when the next one is received, all previous images remain in their thumbnails and exhibit the fault (they can be partially wiped by a frame over them). It is a bit like the screen effect when you are running out of resources.

A related oddity - I have a larger image box in a frame that I used to magnify the "thumbnail" so it can be inspected in detail by holding the mouse button down on the thumbnail.
(Set BigImage.Picture= Thumbnail(Index).Picture)
Only the last thumbnail received shows on the big picture while nothing shows in the big image when I click on a previous received image.
Is this as though the image remaining on the older thumbnails is not in memory any longer or is it a directX problem?

This does not happen on my old XP machine with only 500mb memory but happens on my WSindows7 64 bit machine with 4gb memory.
 
Just a 'stab-in-the-dark', but did you try:
[tt]Me.Refresh[/tt] or
[tt]Image1.Refresh[/tt]
when that happens?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
The problem seems not to be whether it is Xp or Win 7.
I proved this by feeding between two Win 7 machines and the images on the reception Win7 machine do not exhibit the effect.
It is something I must be doing in relaying the image file to the second machine - maybe missing some vital part of the header or something. I will experiment further.

Is it possible that when setting the Image1.Picture using the IStream method it point to an area of memory that is being reused by the next arriving image, the visible image still remaining only on the desktop and not in memory?
 
>setting the Image1.Picture using the IStream method

Code, please
 
Problem fixed by indexing everything - see my other related post.
 
Further I found that if I use DeleteObject hBitmap after I have just filled the image control with a picture, it doesn't immediately erase the picture but it causes the picture to exhibit the condition where parts of it can be wiped out by another control and also "sends it to the back" and sets it's picture value to 0.
 
Yes, that would be right. You need to understand that a handle is not quite the same thing as a simple pointer (sometimes they are the same thing, but mostly not).

And then you need to read the GDI documentation to understand the specifics of a handle to a bitmap (hBitmap)
 
The deleteobject was originally necessary to prevent memory leaks.
 
Yes, and if I remember correctly, I suggested it. But the goalposts have now moved, and it might help to understand the ramifications of deleting the object
 
I globally indexed the hBitmap so I can deleteobject the last picture received for that image control just before the next picture is processed. This appears to fix the memory leak.

On looking back over the older examples the only suggestion I can see to retrieve a picture from an Image control was to put it in a propertybag which converts it to a byte array.

What I was interested in was to learn how to access the picture and structure in memory and convert the memory bytes directly to a byte array and wondered if there was a 'GDI' or other function that would do this?

 
>the only suggestion I can see to retrieve a picture from an Image control was to put it in a propertybag

Pretty certain we also covered streams, at least.

But if you really want to get at the bitmap underlying a StdPicture/IPicture, then have a look at the GetDIBits API call. You may also need to refer here:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top