Convert Graphics Format - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 22 of 22

Thread: Convert Graphics Format

  1. #16
    Join Date
    Sep 2000
    Location
    Hungary
    Posts
    2

    Re: i have a lib can help you

    Could you send me the AxtiveX... to convert any image to another
    Thanks
    qualite@broadband.hu









    TZs

  2. #17
    Join Date
    Jun 2000
    Location
    Maryland
    Posts
    181

    Re: i have a lib can help you

    Can you please send it to me too at

    mitikavuma@hotmail.com

    Thanks


  3. #18
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Convert Graphics Format

    Convert BMP to JPG with this code. (Note: Requires vic32.dll available from
    http://www.catenary.com/)

    Code:
    'PLACE ALL THIS IN A new MODULE
    Const NO_ERROR=0
    Declare Function bmpinfo Lib "VIC32.DLL" (byval Fname as string, bdat as BITMAPINFOHEADER) as Long
    Declare Function allocimage Lib "VIC32.DLL" (image as imgdes, byval wid as Long, byval leng as Long, byval BPPixel as Long) as Long
    Declare Function loadbmp Lib "VIC32.DLL" (byval Fname as string, desimg as imgdes) as Long
    Declare Sub freeimage Lib "VIC32.DLL" (image as imgdes)
    Declare Function convert1bitto8bit Lib "VIC32.DLL" (srcimg as imgdes, desimg as imgdes) as Long
    Declare Sub copyimgdes Lib "VIC32.DLL" (srcimg as imgdes, desimg as imgdes)
    Declare Function savejpg Lib "VIC32.DLL" (byval Fname as string, srcimg as imgdes, byval quality as Long) as Long
    
    
    
    ' Image descriptor
    Type imgdes
       ibuff as Long
       stx as Long
       sty as Long
       endx as Long
       endy as Long
       buffwidth as Long
       palette as Long
       colors as Long
       imgtype as Long
       bmh as Long
       hBitmap as Long
    End Type
    
    Type BITMAPINFOHEADER
        biSize as Long
        biWidth as Long
        biHeight as Long
        biPlanes as Integer
        biBitCount as Integer
        biCompression as Long
        biSizeImage as Long
        biXPelsPerMeter as Long
        biYPelsPerMeter as Long
        biClrUsed as Long
        biClrImportant as Long
    End Type
    
    'PLACE THIS IN YOUR FORM DECLERATIONS
    
    private Sub ConvertToJPEG(bmp_fname as string, jpg_fname as string, optional quality as Long)
       Dim tmpimage as imgdes  ' Image descriptors
       Dim tmp2image as imgdes
       Dim rcode as Long
       'Dim quality as Long
       Dim vbitcount as Long
       Dim bdat as BITMAPINFOHEADER ' Reserve space for BMP struct
       'Dim bmp_fname as string
       'Dim jpg_fname as string
    
       'bmp_fname = "test.bmp"
       'jpg_fname = "test.jpg"
    
       If quality = 0 then quality = 75
         
       ' get info on the file we're to load
       rcode = bmpinfo(bmp_fname, bdat)
       If (rcode <> NO_ERROR) then
          msgbox "error: Unable to get file info"
          Exit Sub
       End If
          
       vbitcount = bdat.biBitCount
       If (vbitcount >= 16) then ' 16-, 24-, or 32-bit image is loaded into 24-bit buffer
          vbitcount = 24
       End If
         
       ' Allocate space for an image
       rcode = allocimage(tmpimage, bdat.biWidth, bdat.biHeight, vbitcount)
       If (rcode <> NO_ERROR) then
         msgbox "error: Not enough memory"
         Exit Sub
       End If
         
       ' Load image
       rcode = loadbmp(bmp_fname, tmpimage)
       If (rcode <> NO_ERROR) then
          freeimage tmpimage ' Free image on error
          msgbox "error: Cannot load file"
          Exit Sub
       End If
    
       If (vbitcount = 1) then ' If we loaded a 1-bit image, convert to 8-bit grayscale
           ' because jpeg only supports 8-bit grayscale or 24-bit color images
         rcode = allocimage(tmp2image, bdat.biWidth, bdat.biHeight, 8)
         If (rcode = NO_ERROR) then
             rcode = convert1bitto8bit(tmpimage, tmp2image)
             freeimage tmpimage ' Replace 1-bit image with grayscale image
             copyimgdes tmp2image, tmpimage
         End If
       End If
    
       ' Save image
       rcode = savejpg(jpg_fname, tmpimage, quality)
       freeimage tmpimage
       Kill bmp_fname
       msgbox "picture saved: " & jpg_fname

    Iouri Boutchkine
    iouri@hotsheet.com
    Last edited by Cimperiali; December 11th, 2003 at 09:08 AM.
    Iouri Boutchkine
    iouri@hotsheet.NOSPAM.com

  4. #19
    Join Date
    Dec 2003
    Location
    UK
    Posts
    2

    I have a lib that can help you

    Can you please send me the ActiveX as I don't have Delphi.

    Many thanx

  5. #20
    Join Date
    Dec 2003
    Location
    UK
    Posts
    2

    I have a lib that can help you

    Can you please send me the ActiveX as I don't have Delphi.

    Many thanx

  6. #21
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    To enielezi

    enielezi:
    you should email (or send a private message) to kingwgl or to any other that asked for it, not post a new thread all alone in vb forum with a request that seems really cryptic if not related to this thread...

    Regards,
    Cesare I.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  7. #22
    Join Date
    Apr 2003
    Posts
    322

    Re: i have a lib can help you

    Quote Originally Posted by Surrendermonkey
    Two words and a URL will solve all your woes.
    Twisted Pixel.
    (bananasoft.tripod.com)
    I heartily recommend it, and rest assured I am not connected in any way commercially or otherwise blah blah etc.

    how reliable is it ? It doesn't seem to be very well known.

Page 2 of 2 FirstFirst 12

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center