If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: [VB6] - pointers and bitmaps

Your matter is not a very simple problem

I had the same question several years ago and I realized that there aren't easy way to compare two colors from their codes. The only solution I found (that's not easy at all) is to convert your color code into Cie L*a*b* code. Once you got this, you can proceed to calculate the distance between the two colors you want to compare.

Now I lost the source codes but if you look for in MasterDrive.it there's should still be the topic I opened about this. Enjoy

Re: [VB6] - pointers and bitmaps

Originally Posted by Cereal Killer

Your matter is not a very simple problem

I had the same question several years ago and I realized that there aren't easy way to compare two colors from their codes. The only solution I found (that's not easy at all) is to convert your color code into Cie L*a*b* code. Once you got this, you can proceed to calculate the distance between the two colors you want to compare.

Now I lost the source codes but if you look for in MasterDrive.it there's should still be the topic I opened about this. Enjoy

"there aren't easy way to compare two colors from their codes" then let us simplificate them hehehe
(like i did with my Graphics class(using DIB's) hehehe)
sorry what is 'MasterDrive'?
my big objective is avoid the flicker on Opacity effect(in controls)... then i need more speed than DIB's

Re: [VB6] - pointers and bitmaps

Rather than copying the bitmap to a byte array, you can use CreateCompatibleDC to create a DC (device context), then SelectObject to give the picture the DC. Then you can access the pixels just like it was a PictureBox, so you can compare the colors simply.

Please remember to rate the posts and threads that you find useful.How can something be both new and improved at the same time?

Re: [VB6] - pointers and bitmaps

Originally Posted by WizBang

Rather than copying the bitmap to a byte array, you can use CreateCompatibleDC to create a DC (device context), then SelectObject to give the picture the DC. Then you can access the pixels just like it was a PictureBox, so you can compare the colors simply.

sorry not so simply
i did that before and takes very time to do my TransparentAlphaBlend()(have 2 'FOR''s)
in these case, the changing color, was for help me use the pointers... nothing more
can you give me a very simple Double Buffering sample(just for draw, i don't need an animation)?

Re: [VB6] - pointers and bitmaps

If all you need is to make one color "transparent", thereby allowing a background color to show through, then a very fast method is one involving some BitBlt calls and a few other APIs. No looping through every pixel. It is therefore very very fast. You will find many examples of this on PlanetSourceCode.com, though do watch out for bad code examples. Such examples are especially prone to lacking proper disposal of objects created via API calls. All objects must be destroyed properly to avoid memory leaks.

Please remember to rate the posts and threads that you find useful.How can something be both new and improved at the same time?

Re: [VB6] - pointers and bitmaps

Originally Posted by WizBang

If all you need is to make one color "transparent", thereby allowing a background color to show through, then a very fast method is one involving some BitBlt calls and a few other APIs. No looping through every pixel. It is therefore very very fast. You will find many examples of this on PlanetSourceCode.com, though do watch out for bad code examples. Such examples are especially prone tolacking proper disposal of objects created via API calls. All objects must be destroyed properly to avoid memory leaks.

"All objects must be destroyed properly to avoid memory leaks. " these can slow down the things?

Re: [VB6] - pointers and bitmaps

Sure, as you run low on memory, things start caching to the hard drive, as objects that fit in AVAILABLE MEMORY are loaded back in. Until AVAILABLE MEMORY = 0%, then you have problems. Windows 7 can block things to an extent, but not XP.

Re: [VB6] - pointers and bitmaps

Originally Posted by dglienna

Sure, as you run low on memory, things start caching to the hard drive, as objects that fit in AVAILABLE MEMORY are loaded back in. Until AVAILABLE MEMORY = 0%, then you have problems. Windows 7 can block things to an extent, but not XP.

ok.. now i have another question-out off topic... sorrry:
how DIB's can slow down things?
(if anyone can't tell me, please tell me something for read)

Re: [VB6] - pointers and bitmaps

Originally Posted by WizBang

It not so much that DIBs can slow things down. But poorly written code can slow things down.

In any case, you don't need to use DIBs to do the transparency.

i have these class(builded by me)...
what i need to know if i'm programming correctly with DIB's
i have my 2D Sprite control. if i put several of them in a form(just for draw an image), the form will take very time to show. please tell something
thanks for all

Re: [VB6] - pointers and bitmaps

OK, I've looked over your class file. Although unfamiliar with your particular programming style, I can see many things which could be improved. For instance, you have some Do...Loops, and within the loops there is an If Then Else. This is a case where you could use Do Until or Do While. Also, there is a set of If Then statements within the ChangeImage sub which all have one condition in common. So in this case you could nest these inside one If Then for that common condition rather than test it for each one separately.

Incidentally, you can draw directly onto the surface of the UserControl, so it if often unnecessary to use a separate PictureBox. Even so, passing it as an Object is slower than passing it as a PictureBox.

However, changing a color in an image pixel by pixel is always very slow compared to using the same technique as for transparency. That's what I'd recommend. Rotating an image is of course another matter, but that's not likely to be what's slowing down the loading of the form.

Please remember to rate the posts and threads that you find useful.How can something be both new and improved at the same time?

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.