Results 1 to 3 of 3

Thread: Compressing RTF for Database

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2010
    Posts
    9

    Compressing RTF for Database

    Hello,

    I am developing an application where the user saves a chosen RTF file to a SQL Server database. My problem is that if the file contains an image, the binary becomes too big. Although the database has enough space, it's not very nice to use up space you could save....

    To give an example:

    RTF binary with two text lines ("ABC / efg") = 156 Bytes
    Same 2 lines + 32 kB image = 2.2MB

    I am still confused on which is the best way to solve this. I have thought about creating an "images" table in my database and using a markup to fetch the image when the file is loaded.

    A compression algorythim would also be great but I don't know how efficient it could be.

    What would be the best strategy to solve this??

  2. #2

    Re: Compressing RTF for Database

    I'm not sure how the RTF format stores images; might convert the data to Base64 which could explain the rather large size increase somewhat.

    Regardless, you could invest in the GZipStream and convert your data to binary before saving it, then just store it all in a binary slot.

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2010
    Posts
    9

    Re: Compressing RTF for Database

    Hey formlesstree4,

    thanks for your reply. I ended up using GZipStream (thanks for the suggestion). However, the file is still a little bit too big (700kB).

    I am using a RichTextBox as an editor where the user can copy and paste images (or add them with an Openfiledialog).

    Code:
                    Dim image As Image = image.FromFile(OpenFileDialog1.FileName)
                    Clipboard.Clear()
                    Clipboard.SetImage(image)
                    Me.RichTextBox1.Paste()
    It is pasted automatically so I think it's converted to bitmap. Is there any way to insert this image into the text box without converting it to bitmap (which is what I think it does)?

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width