Re: Skins - a great solution

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Dave (dave5398_at_btinternet.com)
Date: 11/02/04


Date: Tue, 2 Nov 2004 17:50:37 -0000


"Mike D Sutton" <EDais@mvps.org> wrote in message
news:u#AVOqPwEHA.1260@TK2MSFTNGP10.phx.gbl...
> > Thanks, but I think I found a better solution. Try
http://www.thescarms.com
> > Basically you can take any picture - I found a bitmap gives best results
and
> > taking the top left bit as transparent you load it into a picture box
and
> > scan each row of pixels at a time using GetPixel. That way you can
build up
> > a region using CombineRgn with all non-transparent pixels, and set the
forms
> > region to that one, and bingo you're there! It's excellent. No need to
> > worry about rectangular/ rounded or oval regions, it's all automatic -
> > whereever your transparency colour is, there will be a "hole". I
thought
> > the scanning would take a long time, but even in VB it's fast. I
actually
> > built a C++ component to do it quicker and encapsulate all the API
calls.
>
> You think so? Not the case I'm afraid, you're calling exactly the same
code from both languages ;)
>
> > You then cut out areas using something like Photoshop, load them into an
> > array of picture boxes and if you position them over the corresponding
areas
> > in the skin you can get buttons with rollover functionality (using the
> > SetCapture method). It's very effective.
>
> There's a faster version of this technique on
http://www.vbaccelerator.com/
> Incidentally, IIRC the shaped form creator application previously
mentioned also includes a bitmap tracing method which uses the
> same technique.
> One thing to note with this method is that you must use a losslessly
compressed (or uncompressed) image, using a JPEG as the source
> image will not work regardless of high the quality setting was set to when
saving it due to the lossy nature of the compression
> method used with the format.
> Hope this helps,
>
> Mike
>
>
> - Microsoft Visual Basic MVP -
> E-Mail: EDais@mvps.org
> WWW: http://EDais.mvps.org/
>
Thanks Mike.

Yes and no! Yes you are absolutely right that the same API's are called in
both languages. However, C++ loops are obviously faster. Also, as stated,
this is a neat way to encapsulate the API's and avoid all that function
declaring as it's all there in VC++.

I haven't looked at the link yet, but what I wanted to do to speed it up
would be to loop through the pixels in the array, directly, without calling
GetPixel. Clearly, millions of function calls is a big overhead. However,
I don't (yet) know how to get at the byte array from a bitmap handle. If
your link covers that, thanks, if not, could you help me out here?

On the other hand, for all the pix I've tried, even with holes and random
shapes, the form loads fast enough for all purposes, so it may not be
necessary to go the extra step. For elegance, however, you need it!

Finally, JPEGs DO work, "sort of". They are not satisfactory and leave bits
and pieces round the edges. Therefore better to use bitmaps as you say.

Dave



Relevant Pages

  • Re: Loading image byte array
    ... Thanks Frank, I actually got it working myself before I saw your code. ... load the my image like Michael Phillips suggested. ... at that point Then create a Graphics using a fast-access second bitmap (we ... by pixel over to the byte array. ...
    (microsoft.public.dotnet.framework.drawing)
  • Loading image byte array
    ... I recently found a thread where Frank Hileman suggested using the Bitmap ... I load an image from a file into this byte array? ... object in memory and besides it would require me to transfer pixel by pixel ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Loading image byte array
    ... You must load and parse the headers yourself. ... The BITMAPFILEHEADER tells you that you have a valid bitmap and the actual ... location of the bitmap's byte array. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Loading image byte array
    ... You load your bitmap as a memory stream. ... What you have left is a packed DIB. ... bitmap's image byte array. ... I recently found a thread where Frank Hileman suggested using the Bitmap ...
    (microsoft.public.dotnet.framework.drawing)
  • Grouping
    ... Now, I need to call all the records of one type, group them by the ID value, and put only one of the same ID in an array, how to pull this off without loops and easy on the load? ...
    (alt.php)