Deleting Images from specified location?

Dennis DVR
02-01-2005, 03:45 AM
Hi

I don't know if the title suits to what I really wanted, but here are my questions

Would it be possible to delete an Object or images from specific location drawn using API i.e. CreateCompatibleDC etc..?

Would there be any benifit of using API against Picturebox? well surely the answer is yes, but my concern is how much difference will I get in terms of speed?

Ok here's the real scenario:

I have made a Card Control a couple of months ago, It's working fine and I'm satisfied with its performance when using standard Card Images from Cards DLL but my problem is, if I use custom images stored from res file with GIF format everything seems a bit slower for about 2-3 seconds. It's not really that slow but I thought I could tweak it a little using API function instead of a picturebox, so loading custom images from res file would be as faster as loading images from Cards DLL.

Any advice/suggestion?

Sorry if I look like a newbie, programming with images isn't my thing :D

oops... Sorry if I posted in the wrong thread :o ;) :p

noi_max
02-01-2005, 10:25 AM
Some thoughts about loading images vs copying images...

Loading images from files will definetly take up some time. You might consider loading all the images you need at the start and then just copying them around in memory, which should be fast.

This is probably where PaintPicture or BitBlt would come into play.

Is that what you mean? Or is it just that using the .Gifs with standard controls is a lot slower for you?

Let me know.

Dennis DVR
02-01-2005, 08:06 PM
Hi max

Sorry if I wasn't clear enough. Let me explain a little further :)

I have ActiveX Control which display Card images from Cards DLL library or from a Res File. The control runs pretty fine when loading a cards from a DLL (Cards.DLL/Cards32.DLL) my problem is if I tried to load the images from a res file the control run a bit slower, about 2-3 seconds before it finishes loading/display 52 card pictures, so I am thinking of passing the images from a res file to an API function as I already mentioned instead of loading the picture to picturebox, but my concern is how much difference would I get in terms of loading speed if I use API instead of a picturebox?

Thou I'm thinking about the same thing like you suggested to load the picture at startup, but I'm still hoping that I could use GDI+ in replacement for a picturebox.

Thanks Dennis

noi_max
02-02-2005, 09:56 AM
Would there be any benifit of using API against Picturebox? well surely the answer is yes, but my concern is how much difference will I get in terms of speed?

How many pictureboxes are we talking about? Are you using one for each card? Are they loaded as a control array at runtime?

Those Picboxes can load pretty slow, if you're using a LOT of them.


[edit]
Another question. What method are you using to load .GIF files from a resource?
If I'm right, the LoadResPicture only handles bitmaps?

Dennis DVR
02-02-2005, 08:03 PM
Hi max
How many pictureboxes are we talking about?
Maximum of 53 pictureboxes

Are you using one for each card? Are they loaded as a control array at runtime?
Yes and yes

Another question. What method are you using to load .GIF files from a resource?
If I'm right, the LoadResPicture only handles bitmaps?
I'm using LoadResData and the pictures are added to the res file as a Custom file. In addition to that I'm also using OnError's PictureFromRes function to convert the return value of LoadResData which is a byte array to a picture object, so the call is something like:

CardsPicture(Position).Picture = PictureFromRes(LoadResData(701 + vCardBackEmpty, "CUSTOM"))


How about my first question :D

Would it be possible to delete an Object or images from a given location specific? given the left,height,top and width drawn using GDI+ without having to redraw all the images? or I don't have any choice but to redraw it in absence of the target object?

If my first question is not possible, do you have any suggestion or advice how to speed-up the loading of custom images from a res file aside from loading all the images at startup?

Thanks
Dennis

noi_max
02-03-2005, 12:07 PM
Hi dennis!

Not sure about your first question. :huh:

I found a previous thread or two that you made concerning the issue. I hope OnErr0r spots this thread because I'd like to be more informed myself :D

In his thread "Transparent sprite with programmatic mask"
http://www.visualbasicforum.com/showthread.php?t=109862
he manages to not only get a resource file into a Picture object, but also puts it into a DC for blitting.

There is however at least two extra steps involved. Creating a mask and a DC buffer.

I tried to strip that down to a single function, using the code and the other module as a reference.

It seems to work good and load fast using 52 cards but I have one warning:
I don't know for sure whether or not this is leaking memory like crazy :huh:

The idea here is to load all of the cards into memory DC's and then blit them individually to your destination. This foregoes the use of a picturebox control completely.

Again, try this at your own risk. It seems to work really good and fast on my end (in the IDE).

Later

Max.

Dennis DVR
02-03-2005, 10:00 PM
Not sure about your first question. :huh:

It's ok :)

>>It seems to work good and load fast using 52 cards

Yeah, I did some test also, it loads in an acceptable speed. I think I'll just have to play around with this :)

Thanks I really appreciate your help
Dennis

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum