How the data is embedded in the image

please explain this code clearly !!! how the file is embedded inside the image and retrieved back !!!
 Private Sub btn4(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NLabel4.Click
        Using O As New OpenFileDialog With {.Filter = "(Image Files)|*.jpg;*.png;*.bmp;*.gif;*.ico|Jpg, | *.jpg|Png, | *.png|Bmp, | *.bmp|Gif, | *.gif|Ico | *.ico", .Multiselect = False, .Title = "Select image"}
            If O.ShowDialog = 1 Then
                Try
                    Using FS As New IO.FileStream(O.FileName, IO.FileMode.Open)
                        FS.Seek(0, IO.SeekOrigin.End)
                        While Not FS.ReadByte = Asc("|")
                            FS.Position -= 2
                        End While
                        Dim s As String = Nothing
                        While Not FS.Position = FS.Length - 4
                            s &= Chr(FS.ReadByte.ToString)
                        End While
                        Dim Ext As String = Nothing
                        FS.Seek(0, IO.SeekOrigin.End)
                        While Not FS.ReadByte = Asc("*")
                            FS.Position -= 2
                        End While
                        While Not FS.Position = FS.Length
                            Ext &= Chr(FS.ReadByte.ToString)
                        End While
                        FS.Seek(FS.Length - ((s.Length + s) + 5), IO.SeekOrigin.Begin)
                        Using sfd As New SaveFileDialog With {.DefaultExt = Ext, .Filter = "*." & Ext & " | *." & Ext}
                            If sfd.ShowDialog = 1 Then
                                Using FSw As New IO.FileStream(sfd.FileName, IO.FileMode.Create)
                                    While Not FS.Position = FS.Length - (s.Length + 5)
                                        FSw.WriteByte(FS.ReadByte)
                                    End While
                                End Using
                            End If
                        End Using
                    End Using
                Catch ex As Exception
                    MessageBox.Show("There was an error!" & vbNewLine & vbNewLine & "The application will now close.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    Me.Close()
                End Try
            End If
        End Using
    End Sub
    Private Sub btn3(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NLabel3.Click
        Dim ext As String = TextBox1.Text.Substring(TextBox1.Text.LastIndexOf(".") + 1)
        Using SFD As New SaveFileDialog With {.DefaultExt = ext, .Filter = "*." & ext & " | *." & ext}
            If SFD.ShowDialog = 1 Then
                Try
                    Dim ImageBytes() As Byte = IO.File.ReadAllBytes(TextBox1.Text)
                    Dim FileBytes() As Byte = IO.File.ReadAllBytes(TextBox2.Text)
                    Dim FS As New IO.FileStream(SFD.FileName, IO.FileMode.CreateNew)
                    FS.Write(ImageBytes, 0, ImageBytes.Length)
                    FS.Write(FileBytes, 0, FileBytes.Length)
                    FS.WriteByte(Asc("|"))
                    Dim FileSize() As Byte = System.Text.ASCIIEncoding.ASCII.GetBytes(New IO.FileInfo(TextBox2.Text).Length)
                    FS.Write(FileSize, 0, FileSize.Length)
                    FS.WriteByte(Asc("*"))
                    Dim Extention() As Byte = System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox2.Text.Substring(TextBox2.Text.LastIndexOf(".") + 1))
                    FS.Write(Extention, 0, Extention.Length)
                    FS.Close()
                    FS.Dispose()
                    MsgBox("Done")
                Catch ex As Exception
                    MessageBox.Show("There was an error!" & vbNewLine & vbNewLine & "The application will now close.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                    Me.Close()
                End Try
            End If
        End Using
    End Sub

1. the new file which we are creating will be in this order or not 
file_extension * data_file_size | data_file image_file
No.  The file will be in the order in which it is written in the writing routine:
1. Image File
2. Data File
3. "|"
4. Data File Size (ASCII)
5. "*"
6. File Extension (ASCII)
2. explain this snippet .. why we are changing position while we are extract file
 While Not FS.ReadByte = Asc("|")
                            FS.Position -= 2
                        End While
                        Dim s As String = Nothing
                        While Not FS.Position = FS.Length - 4
                            s &= Chr(FS.ReadByte.ToString)
                        End While
                        Dim Ext As String = Nothing
                        FS.Seek(0, IO.SeekOrigin.End)
                        While Not FS.ReadByte = Asc("*")
                            FS.Position -= 2
                        End While
                        While Not FS.Position = FS.Length
                            Ext &= Chr(FS.ReadByte.ToString)
                        End While
                        FS.Seek(FS.Length - ((s.Length + s) + 5), IO.SeekOrigin.Begin)
The file read position is recalculated before each read, depending either on the position of the marker ("|" and "*") or on the length of the data.   That's how each portion is extracted - the position is set to the start of the portion, and that
portion is read for the correct number of bytes.  The portions are extracted from the end back towards the beginning because the markers can only be guaranteed as unique (they are illegal in a filename extension) when searching backwards.
3. after combining the files with the image .. how the created image is visible (even we are not using any algorithm)
That depends on the image file format, but most formats will use header information that describes the location within the file of the various bits of data that are needed to create the image.  The side effect of this is that if there is information
in the file that is not referenced from this header data then it is simply ignored.  That's what this procedure is relying on - because the new data is appended to the end of the file it will not be referenced from the header data and will be ignored.
For a complete description of what this code does and why it works you should refer to the original author.

Similar Messages

  • I make greetings cards and use images downloaded from cardmaking websites eg - cently I find I cannot copy and paste an image from adobe reader which is the how the images are downloaded. Why is this and how do I copy and paste an image on a  adobe reader

    copying and pasting images from adobe.     I make greetings cards and use images downloaded from cardmaking websites eg - printable heaven. Recently I find I am unable to copy and paste the images which are opened in adobe reader. Why ?  How can I overcome this problem.

    Check the document properties; is copying allowed?

  • Tethering and how the image is viewed.

    I shoot tethered and view either full screen or split view.  Is there a way so that as each image is imported that they auto pop up.  I don't want to select a thumbnail view and have to open it.
    Chris

    I am shooting RAW & Jpeg, Nikon d800
    Chris

  • When i Place a PSD in Indesign it comes in at 200+% while the image frame is considerably smaller. How do i place so that the image and image frame match?

    When i Place a PSD in Indesign it comes in at 200+% while the image frame is considerably smaller. How do i place so that the image and image frame match?

    Peter,
    The screenshots tell you everything.
    The second one tells you how the image frame is automatically set up after a one-click place. It's the blue stroked rectangle with the eight control points at each corner and mid-way along the line. This image frame is generated at a proportionally correct height and width for the image it contains.
    Now, if you look at the third screenshot (click on it to see it at a larger size), you will see I've used the direct selection tool (white arrow) to click on the image within the image frame. This CLEARLY shows the image (within the image frame) is substantially larger than the frame generated to contain it. This is indicated by the yellow stroked rectangle with the eight control points at each corner and mid-way along the line.
    Notice that the blue and yellow rectangles are vastly different sizes.
    In InDesign CS5.5, when i clicked to place the image, the image would fit perfectly within its image frame. the blue and yellow rectangles would match.
    I had no need to go click on the proportional fill and centre buttons like i need to do now in CC.
    I have a keyboard shortcut to place. I can't do File > Place for the amount of images i need to place.
    So to reiterate: How do i place an image so that the image and image frame match?

  • Display the images in excel using jsp

    Hi
    I am unable to display the images in excel using jsp. I can display the data. but cannot display the images. It is simply showing the icon without the image. Is there any way to display the images. Pls give some sample code to display the images in excel.
    Thanks in advance.

    Presumably whoever created the images in that Excel document just put links to somewhere on their hard drive. Those links don't mean anything when you put the document on somebody else's computer, which is what you are doing. At least, that is my guess.
    You could spend some time looking at the Excel file to see how the images were put in there. Or you could ask the person who put the images in there.

  • Background of the image?

    Hello again,
    I have an image which has a white background and some stuff drawn in the middle, How can I display it without the white stuff as the background?
    thanks

    You can't magically alter an image without altering it.
    If you don't want to use Photoshop, you could do the identical thing in code, but it's going to be harder.
    You could load the image, and then modify it such that the color white gets replaced with a transparent color.
    How you do that would depend on how the image is represented (e.g., an indexed color model could be altered differently, and probably more easily, than other color models).
    You might be able to find a library that does the image modification for you. I don't think there's anything in the standard library that would do this easily, though I could be wrong.
    Unless there's some reason why you would want the image modification to happen programmatically at runtime, you're probably better off with pre-processing the image with Photoshop.

  • When the image is uploaded on the server and it is displayed on the web pag

    Dear frenz,
    How the image is uploaded on the server which is at the specifiecd URL and it is displayed on the web page?
    Regards,
    Jasmeen

    it is as simple as doing with a java program .Just place the image file inside your webapps folder and the rest will be done by webserver.

  • When replying to a discussion, the images and text are being cutted and moved over

    Hi, using a community site in SP2013, when you post a discussion (ask and discuss) you have all the text and images displayed correctly. But, when you reply to the post and then, your name is added to the post, the image and text are somehow cutted. I played
    with the options like lock ratio and everything, but it doesn't seem to work, I also played with the webpart options, but, it is not working, the idea is to feed the text and images into the whole respond to the post. Have you seen this issue or behavior before?.
    See below,
    When you reply to the post,
    Can you see how the image is moved over.

    Hi Javi,
    I checked the discussions list in my environment, and the image showed as below when replying to a discussion:
    It seems that the page has been customized.
    I recommend to check the things below:
    Check if the page with issue has been customized.
    Add the site to trusted sites and add to compatibility settings in Internet Explorer.
    Use another browser to access the page to see if the issue still occurs.
    Best regards,
    Victoria
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Way to toggle back to how the shot used to be?

    Let's say you change lens perspective, and a few of the basic things like exposure etc. You click done.
    The you open the image again in ACR. Is there a quick way to toggle back to see how the image was originally?
    Also: is there a way to get rid of phone wires in ACR (i.e. content aware)
    and if you play with something complex like spot remove, how to you cancel out without canceling out your previous adjustments?
    Sorry for all the ACR questions, but I just returned from a trip and am trying to do adjusments now in ACR instead of converting to PSD as usual.

    "camera raw defaults is great, but then you cannot get back to the five adjustments you just made!"
    If you have done nothing else after clicking on Camera Raw Defaults in the Camera Raw Settings Menu you can undo by pressing control-Z, which will return you to the image settings.  (Control-Z will toggle between the two.)  Later on, you can get back to to setting when you opened file in ACR by clicking on Image Settings in the Settings menu.
    "I've been using the reset CR defaults for years.  Is there a difference between that and just regular CR defaults?"
    Selecting Camera Raw Defaults will use the saved default settings for a specific camera, camera model, or ISO setting.  Reset Camera Raw Defaults will restore the original default settings for the current camera (+ camera model, or ISO setting if so set).  So I'd guess they would perform equivalent actions if you had not saved and were not currently using other defaults for the current camera (that is, you've nto used save and load settings).
    "I see snapshots for first time. How does one activate it (preplan)? This is ACR way of history?"
    Similar to PS history snapshots except snapshots persist with raw file edits not disappear when closing image file as with PS).  You create a snapshot by using the Snapshot tab:  Click on the New Snapshot button at the bottom of the Snapshots tab to create a snapshot; then type a name in the New Snapshot dialog box and click OK.  The snapshot will appear in the Snapshots tab list.  (Control+Shift - S is keyboard shortcut.)  Then click on a snapshot name to change the current image settings to those of the selected snapshot.

  • How Can I Clean up Imported Bitmap Images

    Hi, I am using Flash 5. I have imported a sequence of .png images and they are looking pretty rough and bitmapped so I wanted to clean them up.
    1. Do I have to select each frame after import and adjust the bitmap settings for each image or can I doo this somewhere so it affects al images?
    2. I can’t find the settings for cleaning up the bitmap images. I thought they would be in the “Properties” panel?
    3. Is there a way to fix the rasterization or clean up an imported .swf or is it better to clean up the sequence before saving as an .swf?

    Ned Murphy wrote:
    Ideally you should have images cleaned up/ properly sized / optimized before you import them into Flash.  Once they are in Flash, one thing you can do that can help how the image displays, especially if you manipulate its size while in Flash, is to set the image to allow smoothing.  This can be set using code or can be manually applied to the image in the library by right clicking it, selecting Properties, and checking the option to Allow Smoothing.
    Thanks Ned,
    Wow, exactly what I was looking for. Thanks. A huge improvement in the look of the gradients.

  • How can I get the image data from Clipboard with LV

    Anybody knows How can get the image data after pressd "print screen button" with LV?
    I want to program a software which can save a image as a bmp or jpeg etc, and the image data is from pressed print screen button. 
    How to get it out from clipboard. I am trapping about. thanks in advance.
    Try to make everything Automatic

    You can have a look at Rolf Kalbermatter's post here (give him stars) or, if you're using scripting, you can use the Application class Get Clipboard Image method.
    Try to take over the world!

  • How do I save pages from my website in PDF, and prove the image was capture on a given date?

    How do I save pages from my website, [link removed] into a PDF file, with proof of the date the pdf file was created on? I need to display the content of each unique url of my site in PDF format for compliance purposes, and prove the image was taken from a given date. Anyone can help that would be great.

    Impossible to do with Reader. If you own Acrobat and use Create PDF from Webpage. The document will have a creation date. If you then sign the pdf on the date of creation, you have proof of when the document was created and proof that the document wasn’t altered since signed.

  • How to receive the images / binary data t ype

    How to receive the images / binary data type in webdynpro....
    i have a website that let's the user send email, the email attachment and message are stored in both in images data type....
    q1) can i stored the message into binary data type...but the message is very long.....
    q2) if i have a textbox ...i surely will need to display the message  in string ,right ?
    [......... msg here ........]
    what is the codes to receive the images / binary data type in webdynpro....

    As in your previous post if you are storing them as BLOB object.. am sure you are able to get a byte stream or byte array(bytes[]) out of it.
    There should be some way to identify if its a image or a message BLOB. If its a image , convert into bytes and use 
       WDWebResource.getWebResource(bytes,resource type).getAbsoluteURL()
    to obtain the url.. assign this image UI element..
    In case its the message , use bytes.toString to get the message ..
    Regards
    Bharathwaj

  • How can I know the length of the image data section of a PSD file

    I'm a C++ programmer developing a project to parse PSD files, and it's necessary to know whether there is a length field indicating the length of the image data in image data section of a PSD file, if not, how can I know the length?
    Thank you.

    Sorry I can't help, maybe there is some information in the SDK?
    http://www.adobe.com/devnet/photoshop/sdk.html
    Or someone might be able to help in this forum?
    http://forums.adobe.com/community/photoshop/photoshop_sdk

  • How to print the date the image was taken as a watermark on the image

    I want to print the date the image was taken (available as EXIF-data) as an automatic watermark (or otherwise as a caption ON the photo, and not as a header of a footer above or under the photo). I can't find how to do it. Any help? Thanks!

    The only way you could batch this with out of the box PE is to put in via process multiple files in the editor, but you'd have to manually type it in and can only do one date per batch of files. So you could do all the photos taken on one day in one batch, but not a group taken on different days.

Maybe you are looking for

  • How can I change slideshow speed?

    A friend of mine send me a Quicktime movie with a slideshow of several pictures with a Ken Burns effect and with a background music. What had impressed me is that the transitions between the pictures were faster or slower if the music was slower or f

  • Transferring email from old imac running 9.2 to new imac with Tiger?

    I have a newer G5 imac and I want to trasfer my emails from my old computer (imac running OS 9.2) I was using Microsoft outlook express. Now I'm using apple's "Mail" problem. I tried copying over my identities folder but "Mail" would not import them.

  • Toolbox won't open in HP Solution Center

    I am running Win 7 and I have an HP F4580 all-in-one printer. I can't open the toolbox when I get into the HP Solution Center. Any ideas?

  • Need Help with App World on the Blackberry Curve 9300

    Right i got the new Blackberry curve 9300 about a week ago. All my mates already have blackberry curves 8520's. I downloaded App World to get the same theme has my mate, but when i go on his it says he has over 1300 themes on his App World and i only

  • Static in GarageBand when using Apogee Jam

    Hello, I am using an Apogee Jam as my guitar interface with GB. I have noticed static/noise when I am playing. I have GB version 6.0.5. I never had any static before. I have checked my cables and it does it with all my cables. I'm not sure if it is m