Solved

Merge TIFF Files

Posted on 2014-04-24
7
347 Views
Last Modified: 2014-05-04
Hello Experts!!!
I need some help with this one!
I'm creating TIFF images on the fly, but I need to stack them in a file with offsets in an XML File.

For example 3 tiff images in one file
The first one starts at offset 0 and for size of 3211
The Second one starts at 3211 and for size of 1547
The Thrid one starts at 4758 and for size of 1465

I hope you get the idea...I need to stack them up so another application can read the offet and size to pull the image out from the one file.

How can I accomplish this?

Here is my code that generates the images, but as I create them how can I merge them into one file?

'Image Information:
        Dim ImgOffset As Int32 = 0
        Dim ImgLength As Int32 = 0
        Dim ImgResolution As Int32 = 200
        Dim ImgHeight As Int32 = 574
        Dim ImgWidth As Int32 = 1312

        Dim ImageWriter As IO.FileStream = New IO.FileStream("C:\TestImage.tif", FileMode.Create)
        Dim memstrm As IO.MemoryStream = New IO.MemoryStream
        Dim ticket As New Bitmap(ImgWidth, ImgHeight)

        'Fonts:
        Dim TicketID_Font As New Font("Arial", 20, FontStyle.Regular)

        Dim ticketGraphics As Graphics = Graphics.FromImage(ticket)
        ticketGraphics.FillRectangle(Brushes.White, 0, 0, ImgWidth, ImgHeight)
        ticket.SetResolution(ImgResolution, ImgResolution)

        ticketGraphics.DrawString("-- My Ticket --", TicketID_Font, Brushes.Black, 520, 90)
        ticketGraphics.DrawString("Ticket ID: 800001", TicketID_Font, Brushes.Black, 10, 160)
        ticketGraphics.DrawString("Ticket Amount: 111", TicketID_Font, Brushes.Black, 10, 200)
        ticketGraphics.DrawString("Date: " & Now().ToShortDateString, BatchID_Font, Brushes.Black, 10, 240)

        ticket.Save(memstrm, System.Drawing.Imaging.ImageFormat.Tiff)
        memstrm.WriteTo(ImageWriter)
        ImgLength = memstrm.Length

        ticket.Dispose()
        memstrm.Close()
        memstrm.Dispose() 

Open in new window


In the above example I can get the Image Length to put into my XML file, where I'm getting stuck is how can I add my next image to my File Stream (ImageWriter)?

I've done append on the File Stream...but the receiving application doesn't like that so it may need to be something like multi-page to merge them together.

Can someone provide me with an example of taking my code and creating a merged file?

Thanks,
Mark
0
Comment
Question by:smithmrk
7 Comments
 
LVL 52

Assisted Solution

by:Joe Winograd, EE MVE
Joe Winograd, EE MVE earned 50 total points
ID: 40021785
Hi Mark,
I'm glad to see that you found the question I referred you to that kaufmed answered brilliantly, and then you posted this new question, but does this mean that you're abandoning the previous question, which you haven't closed yet? Regards, Joe
0
 

Author Comment

by:smithmrk
ID: 40021811
I haven't abanded anything until I figure this thing out.
I'm leaving all my opitions open.

Stay tune and if you can find any more related questions and answers I'm open to anything!

Thanks,
Mark
0
 
LVL 52

Expert Comment

by:Joe Winograd, EE MVE
ID: 40021823
Fair enough!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 150 total points
ID: 40022091
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 300 total points
ID: 40022742
To be clear:  Do you want a multi-page TIFF, or a single file that has multiple TIFFs embedded within it (not exactly a single-page TIFF).
0
 

Author Closing Comment

by:smithmrk
ID: 40027308
Kaufmed,

I was able to figure it out based on the code you had in the previous post.
That was wonderful and it really helped me figure out what I needed to do to get through my issue.

I needed a single file that has muliple TIFF's embedded within it...NOT a Multi-Page.

I appreciate you putting that code together for that other post and THANKS JOE for finding that solution for me.

Althought I didn't take a look at your links CodeCrusier if I ever need a Multi-Page Tiff I will review them and thanks for weighing in on my post!

Thanks everyone!!!

Mark
0
 
LVL 52

Expert Comment

by:Joe Winograd, EE MVE
ID: 40041039
Mark,
You're welcome...happy to help, albeit in a minor way on this one. I'm glad to hear that you figured it out based on kaufmed's code, and I hope you'll post the solution here so other members looking for something similar can find it...much as you did with kaufmed's code. That's what the EE community is all about...helping each other. Thanks, Joe
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now