See the top rated post in this thread. Click here

Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32

Thread: show DWG file thumbnail image

  1. #21
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: show DWG file thumbnail image

    Brilliant, brilliant, brilliant!! I knew there was some sort of bit by bit code out there that worked!! This did the trick (with a few modifications to fit my code) I basically understand NONE of it but figured enough out as to where to place the STRUCTURE and such and then simply passed my filename to the bitmap object. Thanks to all who have contributed! Thank you so much!

  2. #22
    Active Member
    Join Date
    2009-08
    Posts
    93
    Login to Give a bone
    0

    Default Re: show DWG file thumbnail image

    What do you not understand I will explain it if need be

  3. #23
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: show DWG file thumbnail image

    Quote Originally Posted by jeffhornsby View Post
    What do you not understand I will explain it if need be
    Actually... I need to invert the colors of the bitmap object before it's passed to the picturebox to correct the "white washout" but all the code I found seems to not like "indexed" bitmaps. Any ideas on how to invert the colors? Remember, I'm NOT using the thumbnailviewer class download but the bit by bit version of the code posted. Since I now have the extracted bitmap thumbnail from the drawing file saved as a System.Drawing.Bitmap, shouldn't there be an easy way to invert the colors? Actually, and easy way was found but once again an error occurs stating you can't change the pixels of an indexed bitmap... or something like that.

    Much appreciation (you have no idea how long I've searched for all of this)

  4. #24
    Active Member
    Join Date
    2006-08
    Location
    Brisbane : GMT+10
    Posts
    87
    Login to Give a bone
    0

    Default Re: show DWG file thumbnail image

    Actually, and easy way was found but once again an error occurs stating you can't change the pixels of an indexed bitmap... or something like that.
    What was the code you tried ??

    and what was the actual error message. ?

  5. #25
    Active Member
    Join Date
    2009-08
    Posts
    93
    Login to Give a bone
    0

    Default Re: show DWG file thumbnail image

    You cn set the picture box background to be black and I added a little code so you did not have to look at the whole file path

    Now that Kerry stop by at least you got someone who knows what their doing.

    In the picture you can see how to set some settings to change Auto, zoom, center etc..
    I know you can improve the images unlike AutoCAD's API, luckily there is a ton of info for .NET

    Code:
     Private Shared folderName As String = ""
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If Fbd.ShowDialog = Windows.Forms.DialogResult.OK Then
                folderName = Fbd.SelectedPath
                lstbxFiles.Items.Clear()
                For Each fName In Directory.GetFiles(folderName, "*.dwg")
                    Me.lstbxFiles.Items.Add(Path.GetFileNameWithoutExtension(fName))
                Next
            End If
        End Sub
    
        Private Sub lstbxFiles_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstbxFiles.SelectedIndexChanged
            Dim db As Database = New Database(False, False)
            Dim fname As String = lstbxFiles.SelectedItem.ToString()
            db.ReadDwgFile(folderName & "\" & fname & ".dwg", FileOpenMode.OpenForReadAndReadShare, False, "")
    
            Dim tmbNail As Bitmap = db.ThumbnailBitmap
            picBox.Image = tmbNail
        End Sub
    Attached Images Attached Images
    Last edited by Jeff H; 2010-09-22 at 04:12 AM.

  6. #26
    Active Member
    Join Date
    2009-08
    Posts
    93
    Login to Give a bone
    0

    Default Re: show DWG file thumbnail image

    This saves them to file but one of the overloads is a memory stream if it is easer to use a png or gif or whatever then you could probably paint the picture box
    Code:
    db.ThumbnailBitmap.Save.("C:\AcadImages\Doc.Png",System.Drawing.Imaging.ImageFormat.Png)
    or
    db.ThumbnailBitmap.Save.("C:\AcadImages\Doc.Png",System.Drawing.Imaging.ImageFormat.Gif)

  7. #27
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: show DWG file thumbnail image

    Quote Originally Posted by Kerry Brown View Post
    What was the code you tried ??

    and what was the actual error message. ?
    I used this code right after the system.drawing.bitmap was created and just before I passed it to the picturebox:
    (without this code the image shows with no errors)

    Code:
            Dim x As Integer
            Dim y As Integer
            For x = 0 To image.Width - 1 Step 1
                For y = 0 To image.Height - 1 Step 1
                    Dim clr As Color = image.GetPixel(x, y)
                    Dim clr2 As Color
                    If InvertAlpha Then
                        clr2 = Color.FromArgb(255 - clr.A, 255 - clr.R, 255 - clr.G, 255 - clr.B)
                    Else
                        clr2 = Color.FromArgb(clr.A, 255 - clr.R, 255 - clr.G, 255 - clr.B)
                    End If
                    image.SetPixel(x, y, clr2)
                Next
            Next
    and got the error "SetPixel is not supported for images with indexed pixel formats"

    I did take out the "InvertAlpha" stuff. The way I read the web site I got this from seemed to indicate that this was an optional setting for whether or not you wanted to invert the image and since I always want to.. I took it out.

  8. #28
    Active Member
    Join Date
    2006-08
    Location
    Brisbane : GMT+10
    Posts
    87
    Login to Give a bone
    0

    Default Re: show DWG file thumbnail image

    The way I read the web site I got this from seemed to indicate < ... >
    And the reference is ??

  9. #29
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: show DWG file thumbnail image

    Sorry. A Google search for "Drawing.bitmap invert colors" comes up with:

    http://www.dreamincode.net/code/snippet2056.htm

  10. #30
    Active Member
    Join Date
    2006-08
    Location
    Brisbane : GMT+10
    Posts
    87
    Login to Give a bone
    0

    Default Re: show DWG file thumbnail image

    The code you posted ... was that in-line or a public function ?

Page 3 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. API type question: Replace Revit Thumbnail Image
    By Marek Brandstatter in forum Revit Architecture - General
    Replies: 10
    Last Post: 2018-02-09, 06:36 PM
  2. Drawing File Thumbnail Preview
    By Coolmo in forum Dot Net API
    Replies: 3
    Last Post: 2010-03-19, 09:55 AM
  3. Updating Preview thumbnail image in sheet sets
    By mf in forum AutoCAD Sheet Set Manager
    Replies: 3
    Last Post: 2006-09-13, 04:54 PM
  4. AutoCAD 2005 TIFF Image files - Image file not valid
    By richard_hamilton in forum AutoCAD General
    Replies: 3
    Last Post: 2004-09-30, 11:39 PM
  5. multiple image show
    By nigel.chesworth in forum AutoCAD General
    Replies: 2
    Last Post: 2004-09-14, 11:11 PM

Posting Permissions

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