Hotspots in .Net - Page 3
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 43 of 43

Thread: Hotspots in .Net

  1. #31
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,985

    Re: Hotspots in .Net

    Once one "plays with" the two image approach and is comfortable in understanding its operation, it should not be difficult to make the jump to slight restrictions in the image colors. e.g. only even shades so that the least significant bit is not used to convey color, but rather conveys (part of) the mask.
    Have any code? I was trying to figure out how you'd go about setting LSB of the original image...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  2. #32
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: Hotspots in .Net

    Quote Originally Posted by dglienna View Post
    Have any code? I was trying to figure out how you'd go about setting LSB of the original image...
    I answered that publically back in Reply #8, (and also sent you detailed information via PM....

    Step #1: AND each pixel with 0xFFFEFEFE
    Step #2: Convert Hot Spot ID 1-7 into 0X000001, 0X0000100, 0X0000101, 0X010000, 0x010001, 0x010100, 0x010101
    Step #3: Or Value with color.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #33
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,985

    Re: Hotspots in .Net

    Use a 24/32 bit format. (Convert IMAGE using ??)
    Make sure the "real" picture has only EVEN color values (LSB or R,G,B are 0.) (That's the tough one)
    Maybe I'm missing something. What program would I use for that?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #34
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: Hotspots in .Net

    Quote Originally Posted by dglienna View Post
    Maybe I'm missing something. What program would I use for that?
    You WRITE one.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  5. #35
    Join Date
    Jun 2004
    Location
    NH
    Posts
    674

    Re: Hotspots in .Net

    You WRITE one.
    Which is something you apparently couldn't do easily, or at all?

  6. #36
    Join Date
    Mar 2007
    Location
    Argentina
    Posts
    579

    Re: Hotspots in .Net

    Quote Originally Posted by GremlinSA View Post
    Sorry Guy's ..

    Not quite sure what the hell happened there, Posted it the same way i always do ... however somehow i think something got Fed.. When i check the original zip on my system, it also gave errors..

    Heres a new zip .. (tested this time, and it does have everything in it ...) [.NET 2008 (2.0 Framework)]
    Just for fun, I wanted to copy each masked area to a new image.

    Found some code for fast copying, and adapted.

    But I can't copy back the masked images into picturebox. Just stuck in
    Code:
    Dim ms As MemoryStream = New MemoryStream(Array.ConvertAll(Source, New Converter(Of Int32, Byte)(Function(v As Int32) CByte(v))))
            Destiny = Image.FromStream(ms)
    (I found that code, and copied the above code.)

    There is no way the Image destiny can know the width, height, and PictureFormat to load that stream.

    Also tried to invert my packing code, but don't understand well how to marshall it (I put comments at the end of the routine.)
    Attached Files Attached Files
    [Vb.NET 2008 (ex Express)]

  7. #37
    Join Date
    Mar 2007
    Location
    Argentina
    Posts
    579

    Re: Hotspots in .Net

    Quote Originally Posted by Marraco View Post
    Just for fun,
    ...
    Also tried to invert my packing code, but don't understand well how to marshall it (I put comments at the end of the routine.)
    I forget to say the routine is
    Code:
      Friend Sub ConvertToImage(ByRef Source As Integer(), _
                                  ByRef Destiny As Image)
    and is in the Utilities.vb module.
    [Vb.NET 2008 (ex Express)]

  8. #38
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: Hotspots in .Net

    Quote Originally Posted by TT(n) View Post
    Which is something you apparently couldn't do easily, or at all?
    I already posted the code. What I typically do is use PhotoShop, reduce the color depth of the original image, add a layer with the appropriate color for each hotsopt then simply merge the image.

    But it CAN easile be done in ANY language and used on ANY platform simply by iterating the pixels and performing the steps posted.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  9. #39
    Join Date
    Jun 2004
    Location
    NH
    Posts
    674

    Re: Hotspots in .Net

    I already posted the code. What I typically do is use PhotoShop, reduce the color depth of the original image, add a layer with the appropriate color for each hotsopt then simply merge the image.

    But it CAN easile be done in ANY language and used on ANY platform simply by iterating the pixels and performing the steps posted.
    Technically you haven't posted any code in this thread.
    Don't try and take credit for Grem's code, or even his idea since you've already opposed it, as being a two picture solution.

    I think you need mental help. I'm putting you on my ignore list.

  10. #40
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: Hotspots in .Net

    For those who can not find the original material on stegography and its utilization for hotspots, or have problems with the c++ implementation in the article, here is a (non-optimized) VB.NET

    Code:
    Public Shared Sub Encode(ByVal src As Bitmap, ByVal mask As Bitmap, ByVal key As List(Of Color))
        Dim x As Integer
        For x = 0 To src.Width - 1
            Dim y As Integer
            For y = 0 To src.Height - 1
                Dim rgb As Integer = (src.GetPixel(x, y).ToArgb And -65794)
                Dim m As Integer = key.IndexOf(mask.GetPixel(x, y))
                rgb = (rgb Or HotSpot.t(m))
                src.SetPixel(x, y, Color.FromArgb(rgb))
            Next y
        Next x
    End Sub
    
     Public Shared Function HotIndex(ByVal src As Bitmap, ByVal x As Integer, ByVal y As Integer) As Integer
        Dim m As Integer = (src.GetPixel(x, y).ToArgb And &H10101)
        Dim i As Integer
        For i = 0 To 8 - 1
            If (HotSpot.t(i) = m) Then
                Return i
            End If
        Next i
        Return 0
    End Function
    
     Shared Sub New()
        HotSpot.t = New Integer() { 0, 1, &H100, &H101, &H10000, &H10001, &H10100, &H10101 }
    End Sub
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  11. #41
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,985

    Re: Hotspots in .Net

    Thanks. That makes it crystal clear. I think I was hung up on this line:

    Code:
       Dim rgb As Integer = (src.GetPixel(x, y).ToArgb And -65794)
    Plus the fact that I've never used Photoshop. (artistic skills lacking)
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  12. #42
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: Hotspots in .Net

    Quote Originally Posted by dglienna View Post
    Thanks. That makes it crystal clear. I think I was hung up on this line...
    No problem...You really have to stop thinking in decimal

    You should be able to see how to extend by chaning 010101 to 030303 and getting 31 distinct spots.

    Also if the patterns are in a List rather than an array, the explicit for loop can be replated with an IndexOf, and the total amount of code that is needed in the application is a single statement.

    Plus the fact that I've never used Photoshop. (artistic skills lacking)
    Actually the reason I DO use photoshop is because I am completely non-artistic, but you can create plugins that do all of the work based on a mathematical basis.

    As you should now see, the colors for active areas will be VERY VERY close to the colors used for the same visual look, but in non (or different) areas. This does make this approach MUCH more suspectible to any distortion caused by compression and/or stretching. A 0.0000476837158203125% distortion will cause false results.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  13. #43
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hotspots in .Net

    Quote Originally Posted by TheCPUWizard View Post
    Once one "plays with" the two image approach and is comfortable in understanding its operation, it should not be difficult to make the jump to slight restrictions in the image colors. e.g. only even shades so that the least significant bit is not used to convey color, but rather conveys (part of) the mask.
    I've played a little with the idea of moving to only a single image using the LSB of each color as the Hotspot masking ...

    And here is a list of considerations that i feel do not warent doing so...

    1) The Hotspoted Image WILL HAVE TO be stored as a BMP .. Why
    • JPG's loose compresion wreeks havoc on the LSB's, causing a loss of hotspot info ..
    • GIF's Indexed color map. Too stay within the max colors the encoder will merge most of the close colors, again causing a loss of LSB's.
    • Most other image compresion formats also loose LSB data..


    2) In the case of stretched images the image will still need to be loaded twice.
    • First. To the streched/Squeezed picturebox.
    • Second. To a hidden image sixed picturbox
    Because of the unpredictable effect of the stretch code on pixel color's there's a good chance of LSB data loss ...
    looking at simple Color averaging .. if we half the image size, and use the avarage of a 2 * 2 pixel block to select the color (looking at only one byte) and our cube has Color codes : 43,45,47,49 ... (LSB set for hotspot) however our new single pixel will have an averaged color code of 46 (LSB NOT SET) changing our hotspot value.

    3) Applying Multiple masks to a single image requires a new full image for each set.
    Consider the point of an image with multiple levels of focus. Like the one used in my example, if we looking at the foreground, we hotspot only items in the foreground, and ignore the background.. However we could draw up a second mask for it, ignoring the foreground and hot spot each of the seperate fish in the background.

    Using a Seperate mask allows multiple masks to be applied to a single image.

    These are just a few of the issues that I can foresee in the use of LSB's for hotspoting .. BUT I"M NOT SAYING that you cant use it, it's still worth a try..

    Gremmy..
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Page 3 of 3 FirstFirst 123

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center