Results 1 to 11 of 11

Thread: Extract a image from RTF ? WMF > BMP

  1. #1

    Thread Starter
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331

    Question Extract a image from RTF ? WMF > BMP

    Hi,
    I use this code to export a selected image in a rtf file to BMP...

    VB Code:
    1. If is_image(fMainForm.RichText2.SelRTF) = True Then
    2.         SendMessage fMainForm.RichText2.hwnd, WM_COPY, 0, 0
    3.         fMainForm.Picture6.Picture = Clipboard.GetData()
    4.         fMainForm.Picture6.Refresh
    5.         SavePicture fMainForm.Picture6.Picture, App.Path & "\Temp\object_" & Str(lngCurText&) & ".bmp"
    6.         strHTML$ = strHTML$ & "<img src=object_" & Str(lngCurText&) & ".bmp>"
    7.        End If

    But when I try to open the extracted BMP is MS PAINT or some other pic editor it says invalid format ....... The browser does not display the image either .....

    Can some one please help me ?
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

  2. #2
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    Since the data stored in the clipboard is raw BMP data (with a header), couldn't you just get a pointer to the start of the BMP data in the clipboard, copy it to your own byte array, and save that as a file? It would be much more efficient than your current method.

  3. #3

    Thread Starter
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331

    Question i don't know how ?

    This is what happens ........
    see the jpeg
    Attached Images Attached Images  
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

  4. #4
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    I think the problem here is the Bitmap Header version. Later versions of the Windows BMP actually allow JPEG compression I think (so it says in MSDN anyway).

    SavePicture function might save as BITMAPV5HEADER but your copy of mspaint.exe might only be able to read BITMAPV4HEADER or so.

    The trick around this is to open it up in a decent graphics program and save as an older bitmap. Paint isn't exactly known for it's superb power.

  5. #5

    Thread Starter
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331

    Windows Explorer shows a preview of the invalid BMP...

    Windows Explorer shows a preview of the invalid BMP...
    But I can't open it in MSPaint ...... or MS Photo Editor....

    I have a code that converts BMP to JPEG ........ but even that won't work with this Invalid BMPs ..........
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

  6. #6
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    Can you attach the actual bitmap? I will see if I can spot the problem.

  7. #7

    Thread Starter
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331

    here it is

    Try inserting it to a web page .......... then it will show it ......
    but still can't open it in MS Paint .....
    Attached Images Attached Images  
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

  8. #8
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    WGTN, New Zealand
    Posts
    338
    I found this inside the file:

    Code:
    Mic oso t V sua  St dio VB9 \my sof war \si hal tex \te p.b p
    The blank spaces are actually null characters.

    Are you sure you are saving this as a BMP? The header does not resemble a BMPs header, or any other graphics format I know of.

  9. #9

    Thread Starter
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331

    i guess so ....

    SavePicture .... saves bitmaps right ?
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

  10. #10
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871
    Odd... on my system (XP) the Windows Viewer opens the file, as well as MS Paint. Photoshop, ImageReady and Acrobat Reader refuse though...
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  11. #11

    Thread Starter
    Hyperactive Member Dasiths's Avatar
    Join Date
    Apr 2001
    Location
    Colombo, Sri Lanka
    Posts
    331

    on IE 5.0

    When i insert that bmp into a web page using a img tag it displays correctly .........

    When you right click it and click "save image as ..." the default option is to save as WMF .......... ????
    It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
    -Aristotle As quoted in Rapid Development, chapter 8, page 167.

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