Announcement

Collapse
No announcement yet.

BMP 2 JPG using Intel's JPEG Lib

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • BMP 2 JPG using Intel's JPEG Lib

    Hi there,

    tried to use the Intel JPEG Library with pbdll over the holidays.
    Code below is a PORT FROM VB TO pbdll.
    You'll find the VB code at [link]http://vbaccelerator.com/[/link]
    The JPEG Lib is at [link]www.intel.com[/link]
    It works with some bitmaps but most bitmaps produce a error
    %IJL_UNSUPPORTED_SUBSAMPLING OR %IJL_INVALID_JPEG_PROPERTIES in
    the function savejpg at line - ijlWrite(VARPTR(tJ), %IJL_JFILE_WRITEWHOLEIMAGE)

    I guess the fault is a improper JPEG_CORE_PROPERTIES_VB type declare.
    Which value shall i use for enum types ? Long or integer ?

    Does anyone use the Intel JPEG Library with PBDLL ?
    Best rgds
    Ralph


    Code:
    #COMPILE EXE
    #INCLUDE "win32api.inc"
    
    
    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' constants and prototype for ijl10.dll
    'Private Enum IJLERR
    
    ' The following "error" values indicate an "OK" condition.
    %IJL_OK = 0
    %IJL_INTERRUPT_OK = 1
    %IJL_ROI_OK = 2
    
    %IJL_EXCEPTION_DETECTED = -1
    %IJL_INVALID_ENCODER = -2
    %IJL_UNSUPPORTED_SUBSAMPLING = -3
    %IJL_UNSUPPORTED_BYTES_PER_PIXEL = -4
    %IJL_MEMORY_ERROR = -5
    %IJL_BAD_HUFFMAN_TABLE = -6
    %IJL_BAD_QUANT_TABLE = -7
    %IJL_INVALID_JPEG_PROPERTIES = -8
    %IJL_ERR_FILECLOSE = -9
    %IJL_INVALID_FILENAME = -10
    %IJL_ERROR_EOF = -11
    %IJL_PROG_NOT_SUPPORTED = -12
    %IJL_ERR_NOT_JPEG = -13
    %IJL_ERR_COMP = -14
    %IJL_ERR_SOF = -15
    %IJL_ERR_DNL = -16
    %IJL_ERR_NO_HUF = -17
    %IJL_ERR_NO_QUAN = -18
    %IJL_ERR_NO_FRAME = -19
    %IJL_ERR_MULT_FRAME = -20
    %IJL_ERR_DATA = -21
    %IJL_ERR_NO_IMAGE = -22
    %IJL_FILE_ERROR = -23
    %IJL_INTERNAL_ERROR = -24
    %IJL_BAD_RST_MARKER = -25
    %IJL_THUMBNAIL_DIB_TOO_SMALL = -26
    %IJL_THUMBNAIL_DIB_WRONG_COLOR = -27
    %IJL_RESERVED = -99
    
    'END Enum
    
    'Private Enum IJLIOTYPE
    %IJL_SETUP = -1&
    ''// Read JPEG parameters (i.e., height, width, channels,
    '' sampling, etc.) from a JPEG bit stream.
    %IJL_JFILE_READPARAMS      = 0&
    %IJL_JBUFF_READPARAMS      = 1&
    '' Read a JPEG Interchange Format image.
    %IJL_JFILE_READWHOLEIMAGE  = 2&
    %IJL_JBUFF_READWHOLEIMAGE  = 3&
    '' Read JPEG tables from a JPEG Abbreviated Format bit stream.
    %IJL_JFILE_READHEADER      = 4&
    %IJL_JBUFF_READHEADER      = 5&
    '' Read image info from a JPEG Abbreviated Format bit stream.
    %IJL_JFILE_READENTROPY     = 6&
    %IJL_JBUFF_READENTROPY     = 7&
    '' Write an entire JFIF bit stream.
    %IJL_JFILE_WRITEWHOLEIMAGE = 8&
    %IJL_JBUFF_WRITEWHOLEIMAGE = 9&
    '' Write a JPEG Abbreviated Format bit stream.
    %IJL_JFILE_WRITEHEADER     = 10&
    %IJL_JBUFF_WRITEHEADER     = 11&
    '' Write image info to a JPEG Abbreviated Format bit stream.
    %IJL_JFILE_WRITEENTROPY    = 12&
    %IJL_JBUFF_WRITEENTROPY    = 13&
    '' Scaled Decoding Options:
    '' Reads a JPEG image scaled to 1/2 size.
    %IJL_JFILE_READONEHALF     = 14&
    %IJL_JBUFF_READONEHALF     = 15&
    '' Reads a JPEG image scaled to 1/4 size.
    %IJL_JFILE_READONEQUARTER  = 16&
    %IJL_JBUFF_READONEQUARTER  = 17&
    '' Reads a JPEG image scaled to 1/8 size.
    %IJL_JFILE_READONEEIGHTH   = 18&
    %IJL_JBUFF_READONEEIGHTH   = 19&
    '' Reads an embedded thumbnail from a JFIF bit stream.
    %IJL_JFILE_READTHUMBNAIL   = 20&
    %IJL_JBUFF_READTHUMBNAIL   = 21&
    
    'END Enum
    
    ' %IJL_BGR       = 24
    %IJL_NONE       = 28
    
    %IJL_RGB        = 1  '' Red-Green-Blue COLOR space.
    %IJL_BGR        = 2  '' Reversed channel ordering FROM IJL_RGB.
    %IJL_YCBCR      = 3  '' Luminance-Chrominance COLOR space AS defined
                         '' by CCIR Recommendation 601.
    %IJL_G          = 4  '' Grayscale COLOR space.
    %IJL_RGBA_FPX   = 5  '' FlashPix RGB 4 channel COLOR space that
                         '' has pre-multiplied opacity.
    %IJL_YCBCRA_FPX = 6  '' FlashPix YCbCr 4 channel COLOR space that
                         '' has pre-multiplied opacity.
    %IJL_411        = 1  '' Valid ON a JPEG w/ 3 channels.
    %IJL_422        = 2  '' Valid ON a JPEG w/ 3 channels.
    %IJL_4114       = 3  '' Valid ON a JPEG w/ 4 channels.
    %IJL_4224       = 4  '' Valid ON a JPEG w/ 4 channels.
    
    TYPE JPEG_CORE_PROPERTIES_VB
      UseJPEGPROPERTIES AS DWORD         ' default = 0
    
      ' DIB specific I/O data specifiers.
      DIBBytes AS LONG                   ' default = NULL 4
      DIBWidth AS DWORD                  ' default = 0 8
      DIBHeight AS INTEGER               ' default = 0 12
      DIBPadBytes AS DWORD               ' default = 0 16
      DIBChannels AS DWORD               ' default = 3 20
      DIBColor AS LONG                   ' default = IJL_BGR 24     enum
      DIBSubsampling AS LONG             ' default = IJL_NONE 28    enum
    
      ' JPEG specific I/O data specifiers.
      JPGFile AS LONG                    ' JPGFile; 32   '// default = NULL
      JPGBytes AS LONG                   ' default = NULL 36
      JPGSizeBytes AS DWORD              ' default = 0 40
      JPGWidth AS DWORD                  ' default = 0 44
      JPGHeight AS DWORD                 ' default = 0 48
      JPGChannels AS DWORD               ' default = 3
      JPGColor AS LONG                   ' default = IJL_YCBCR     enum
      JPGSubsampling AS LONG             ' default = IJL_411       enum
      JPGThumbWidth AS DWORD             ' default = 0
      JPGThumbHeight AS DWORD            ' default = 0
    
      ' JPEG conversion properties.
      cconversion_reqd AS DWORD          ' default = TRUE
      upsampling_reqd AS DWORD           ' default = TRUE
      jquality AS DWORD                  ' default = 75.  100 is my preferred quality setting.
    
      Pad AS DWORD                       ' 8-byte alignment!!!
      jprops (0 TO 19999) AS BYTE
    
    END TYPE
    
    DECLARE FUNCTION ijlInit LIB "ijl10.dll" ALIAS "ijlInit" (BYVAL jcprops AS LONG) AS INTEGER
    DECLARE FUNCTION ijlFree LIB "ijl10.dll" ALIAS "ijlFree" (BYVAL jcprops AS LONG) AS INTEGER
    DECLARE FUNCTION ijlRead LIB "ijl10.dll" ALIAS "ijlRead" (BYVAL jcprops AS LONG, BYVAL ioType AS INTEGER) AS INTEGER
    DECLARE FUNCTION ijlWrite LIB "ijl10.dll" ALIAS"ijlWrite" (BYVAL jcprops AS LONG , BYVAL ioType AS LONG) AS LONG
    DECLARE FUNCTION ijlGetLibVersion LIB "ijl10.dll" ALIAS "ijlGetLibVersion" () AS LONG
    DECLARE FUNCTION ijlGetErrorString LIB "ijl10.dll" ALIAS "ijlGetErrorString" (BYVAL code AS LONG) AS LONG
    
    
    FUNCTION SaveJPG( infile AS ASCIIZ, sFile AS ASCIIZ, BYVAL lQuality AS LONG ) AS INTEGER
        LOCAL tJ        AS JPEG_CORE_PROPERTIES_VB
        LOCAL hBmp      AS LONG
        LOCAL lPtr      AS LONG
        LOCAL lR        AS LONG
        LOCAL fh        AS LONG
        LOCAL bmi       AS BITMAPINFO
        LOCAL bm        AS bitmap
        LOCAL hdc       AS LONG
        LOCAL hdcmem    AS LONG
        LOCAL pixelbuf  AS STRING
        LOCAL hDesktop  AS LONG
        LOCAL bmSize    AS LONG
    
        hBmp  = LoadImage(BYVAL %NULL, infile, %IMAGE_BITMAP,  0 , 0, %LR_LOADFROMFILE )
        IF hBmp = 0 THEN
          MSGBOX "cannot read bmp"
          FUNCTION = %false
          EXIT FUNCTION
        END IF
    
        hDesktop = GetDesktopWindow()
        hdc      = GetDC( hDesktop )
        hdcmem   = CreateCompatibleDC(hdc)
        ReleaseDC hDesktop, hdc
    
        GetObject hBmp, SIZEOF(bm), bm
        bmi.bmiHeader.biSize         = LEN(bmi.bmiHeader)
        bmi.bmiHeader.biWidth        = bm.bmWidth
        bmi.bmiHeader.biHeight       = bm.bmHeight
        bmi.bmiHeader.biPlanes       = 1
        bmi.bmiHeader.biBitCount     = bm.bmBitsPixel
        bmi.bmiHeader.biCompression  = %BI_RGB
    
        '- Calculate space needed for the dib bits
        bmSize = bmI.bmiHeader.biWidth
        bmSize = (bmSize + 1) * (bmI.bmiHeader.biBitCount / 8)
        bmSize = ((bmSize + 3) / 4) * 4
        bmSize = bmSize * bmI.bmiHeader.biHeight
                                             
        '- Allocate the memory
        ON ERROR RESUME NEXT
        pixelbuf = STRING$(bmSize, CHR$(0))
        ON ERROR GOTO 0
        IF ERR THEN
           MSGBOX "Couldn't get the memory"
           FUNCTION = %FALSE
           deleteObject hBmp
           deletedc hdcmem
           EXIT FUNCTION
        END IF
        
        lptr     = STRPTR(pixelbuf)
        GetDIBits hdcmem, hBmp, 0, bmI.bmiHeader.biHeight, BYVAL lptr, bmI, %DIB_RGB_COLORS
    
        ' see what we've got
    '    FH = FREEFILE
    '    OPEN "bin.img" FOR OUTPUT AS fh
    '    PRINT #fh, pixelbuf;
    '    CLOSE fh
        
        lR = ijlInit( VARPTR(tJ) )
        IF lR <> %IJL_OK THEN
          MSGBOX "Failed to init IJL"
          FUNCTION = %false
          deleteObject hBmp
          deletedc hdcmem
          EXIT FUNCTION
        END IF
        
        ' Set up the DIB information:
        tJ.DIBWidth    = bm.bmWidth
        tJ.DIBHeight   = bm.bmHeight
        tJ.DIBBytes    = lptr   '' hBmp '' cDib.DIBSectionBitsPtr
        ''' error with = -8 w/o line = -3 on most bmp's
        tJ.DIBPadBytes = bmi.bmiHeader.biSizeImage - bm.bmWidth  * 3
    
        ' Set up the JPEG information:
        tJ.JPGFile     = VARPTR(sFile)
        tJ.JPGWidth    = bm.bmWidth
        tJ.JPGHeight   = bm.bmHeight
        tJ.jquality    = 75   '' lQuality
    
        ' Write the image:
        lR = ijlWrite(VARPTR(tJ), %IJL_JFILE_WRITEWHOLEIMAGE)
        IF lR = %IJL_OK THEN
           FUNCTION = %True
        ELSE
           MSGBOX "Failed to save to JPG " + STR$(lr)
        END IF
    
        deleteObject hBmp
        deletedc hdcmem
    
        ' Ensure we have freed memory:
        ijlFree VARPTR(tJ)
    
    END FUNCTION
    
    
    FUNCTION PBMAIN()
    
       SaveJPG "splash.bmp", "splash.jpg", 100
    
    END FUNCTION

  • #2
    I'm not sure about the "enum" types, but your function defintions should be changed to indicate the return value is LONG (32-bit) instead of INTEGER (16-bit). This is according to the VB source code from the link you posted.

    -------------
    Lance
    PowerBASIC Support
    ( mailto:[email protected][email protected]</A> )
    Lance
    mailto:[email protected]

    Comment


    • #3
      Hi Lance,
      thanks for the reply. I played around with the fct declares.
      Integer, Long, Pointer don't work. So i go a extra mile and
      wrote a C DLL for Intels JPEG Lib.

      Hi Martin,
      pls respond to the BBS so other's can share your ideas.

      A simple BMP to JPG File conversion is ok for my PBDLL app.
      If there is anyone who want the DLL wrapper and doesn't have
      MS Dev Studio pls let me know. I'll send you the DLL by mail.

      Ralph

      Code:
      #COMPILE EXE
      #INCLUDE "win32api.inc"
      
      DECLARE FUNCTION EdrBMP2JPG LIB "edr.dll" ALIAS "EdrBMP2JPG" _
              (infile AS ASCIIZ, outfile AS ASCIIZ) AS INTEGER
      DECLARE FUNCTION EdrJPG2BMP LIB "edr.dll" ALIAS "EdrJPG2BMP" _
              (infile AS ASCIIZ, outfile AS ASCIIZ) AS INTEGER
      
      
      FUNCTION PBMAIN()
      
         EdrBMP2JPG "test.bmp", "splash.jpg"
         EdrJPG2BMP "splash.jpg", "testnew.bmp"
      
      END FUNCTION
      C Source for edr.dll :
      Code:
      /*----------------------------------------------------------
         EDRLIB.C -- Easy Dll wRapper for Intel's JPEG Library
         BMP to JPEG conversion ( 24 Bit BMPs only )
        ----------------------------------------------------------*/
      #include "ijl.h"
      #include <windows.h>
      __declspec(dllexport) INT EdrBMP2JPG(char[], char[]);
      __declspec(dllexport) INT EdrJPG2BMP(char[], char[]);
      
      
      int WINAPI DllMain (HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
          {
           return TRUE ;
          }
      
      
      int EdrBMP2JPG (char input_filename[], char output_filename[])
          {
          long DIBLineSize;
          HANDLE hbitmapfile;
          HANDLE hFileMappingObject;
          unsigned char *bitmapptr;
          BITMAPFILEHEADER *bmfh;
          BITMAPINFOHEADER *bmih;
          JPEG_CORE_PROPERTIES jcprops;
      
          // create an IJL compressor; initialize with default parameters
          ijlInit(&jcprops);
      
          // Open the bitmap file for output.
          hbitmapfile = CreateFile(input_filename,GENERIC_READ,0,0,OPEN_EXISTING,0,0);
      
          // map the disk file into a memory region.at address bitmapptr
          hFileMappingObject = CreateFileMapping(hbitmapfile,0,PAGE_READONLY,0,0,0);
          bitmapptr = (unsigned char *) MapViewOfFile(hFileMappingObject,FILE_MAP_READ,0,0,0);
      
          // read the input bitmap header
          bmfh = (BITMAPFILEHEADER *)bitmapptr;
          bmih = (BITMAPINFOHEADER *)(bitmapptr + sizeof(BITMAPFILEHEADER));
      
          // determine the width of one line of the input bitmap in bytes
          DIBLineSize = (bmih->biWidth * 3)/4*4;
      
          // initialize the compression paras describing the BMP we are encoding from
          jcprops.DIBChannels = 3;
          jcprops.DIBColor    = IJL_BGR;
          jcprops.DIBHeight   = -bmih->biHeight;
          jcprops.DIBWidth    = bmih->biWidth;
          jcprops.DIBPadBytes = DIBLineSize - bmih->biWidth*3;
      
          // initialize the compression parameters describing the kind of
          // JPEG to create. We are using default values for image quality,
          jcprops.JPGHeight   = bmih->biHeight;
          jcprops.JPGWidth    = bmih->biWidth;
      
          // Set the JPEG compressor to write to the "output.jpg" file
          jcprops.JPGFile = output_filename;
      
          // set the JPEG DIB source to the newly allocated temporary buffer
          jcprops.DIBBytes = bitmapptr + sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER);
      
          // write the entire JPEG image. This creates a JFIF file.
          ijlWrite(&jcprops, IJL_JFILE_WRITEWHOLEIMAGE);
      
          // release the IJL
          ijlFree(&jcprops);
      
          // Release file mapping object and close output file
          UnmapViewOfFile(bitmapptr);
          CloseHandle(hFileMappingObject);
          CloseHandle(hbitmapfile);
      
          return 0;
        }
      
      
      int EdrJPG2BMP (char input_filename[], char output_filename[])
          {
          // declares
          int DIBOffset;
          HANDLE hbitmapfile;
          HANDLE hFileMappingObject;
          unsigned char *bitmapptr;
          BITMAPFILEHEADER *bmfh;
          BITMAPINFOHEADER *bmih;
          JPEG_CORE_PROPERTIES jcprops;
      
          // Open the bitmap file for output.
          hbitmapfile = CreateFile(
        			output_filename,
      			GENERIC_READ | GENERIC_WRITE,
      			FILE_SHARE_READ | FILE_SHARE_WRITE,
      			0,
      			CREATE_ALWAYS,
      			0, 0);
      
          // intialize the JPEG structure
          ijlInit(&jcprops);
      
          // set the IJL data source as the input filename and read JPEG parameters
          jcprops.JPGFile = input_filename;
          ijlRead(&jcprops, IJL_JFILE_READPARAMS);
      
          // calculate the line offset of the output DIB.
          DIBOffset = (jcprops.JPGWidth*3 + 3)/4*4;
          // resize the output bitmap file to the actual size the BMP will represent.
          SetFilePointer(
      			hbitmapfile,
      			DIBOffset * jcprops.JPGHeight + sizeof(BITMAPFILEHEADER)
      			+ sizeof(BITMAPINFOHEADER),
      			0,
      			FILE_BEGIN);
      
          SetEndOfFile(hbitmapfile);
      
          // map the disk file into an addressable memory region at address "bitmapptr"
          hFileMappingObject = CreateFileMapping( hbitmapfile,0,PAGE_READWRITE,0,0,0);
          bitmapptr = (unsigned char *) MapViewOfFile(hFileMappingObject,FILE_MAP_WRITE,0,0,0);
      
          // write the output bitmap header
          bmfh = (BITMAPFILEHEADER *)bitmapptr;
          bmih = (BITMAPINFOHEADER *)(bitmapptr + sizeof(BITMAPFILEHEADER));
      
          bmfh->bfType      = 'MB';
          bmfh->bfSize      = DIBOffset * jcprops.JPGHeight
          		        + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
          bmfh->bfReserved1 = 0;
          bmfh->bfReserved2 = 0;
          bmfh->bfOffBits   = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
      
          bmih->biSize          = sizeof(BITMAPINFOHEADER);
          bmih->biWidth         = jcprops.JPGWidth;
          bmih->biHeight        = jcprops.JPGHeight;
          bmih->biPlanes        = 1;
          bmih->biBitCount      = 24;
          bmih->biCompression   = BI_RGB;
          bmih->biSizeImage     = 0;
          bmih->biXPelsPerMeter = 1;
          bmih->biYPelsPerMeter = 1;
          bmih->biClrUsed       = 0;
          bmih->biClrImportant  = 0;
      
          // set up the DIB specification for the JPEG decoder
          jcprops.DIBBytes    = bitmapptr + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
          jcprops.DIBWidth    = jcprops.JPGWidth;
          jcprops.DIBHeight   = -(int)jcprops.JPGHeight;
          jcprops.DIBColor    = IJL_BGR;
          jcprops.DIBChannels = 3;
          jcprops.DIBPadBytes = DIBOffset - 3*jcprops.JPGWidth;
      
          // read data from the JPEG image into the bitmap
          ijlRead(&jcprops, IJL_JFILE_READWHOLEIMAGE);
          // clean up and destroy the JPEG Decompressor
          ijlFree(&jcprops);
      
          // close the output file
          UnmapViewOfFile(bitmapptr);
          CloseHandle(hFileMappingObject);
          CloseHandle(hbitmapfile);
          return 0;
      }

      Comment


      • #4
        Hi Ralph,

        I would like to receive wrapper dll that you have offered to email. Your email address is not available so I could not send you an email. I am hoping that you will see this message.

        Thanks in advance.

        Gajanan Raje
        [email protected]




        ------------------
        Gajanan Raje

        Comment


        • #5
          I use IMGDLL (which has now been superceded by ISOURCE). At US$25 it is a cheap and comprehensive image manipulation library that handles about 8 formats including JPEG, BMP, WMF, TIFF, etc. www.smalleranimals.com



          ------------------
          Lance
          PowerBASIC Support
          mailto:[email protected][email protected]</A>
          Lance
          mailto:[email protected]

          Comment


          • #6
            Thanks Lance. I will check it out.

            Gajanan Raje

            ------------------
            Gajanan Raje

            Comment


            • #7
              Hi all,

              Intel have released v1.5 of their JPEG library. This version allegedly has VB support, which basically means they've translated that C header file and supplied a sample VB application.
              The code for the sample app looks spookily similar to the VB accelerator code Ralph was working on porting to PB. Not that I'd suggest Intel "borrowed" it without giving any credit to the guy(s) at VB accelerator, no.

              However, getting back to the point, the Intel version looks (after an admittedly brief glance) rather clearer than the original, and should therefore be easier to convert to a proper BASIC. http://developer.intel.com/vtune/PER.../ijl/index.htm



              ------------------
              --Dan
              Dan

              Comment


              • #8
                Guys --
                Is there any success with translation VB sample for ijl15 ?

                ------------------
                E-MAIL: [email protected]

                Comment


                • #9
                  Semen,

                  seems we are doing the same thing at the same time.
                  Please see the Intel's Performance Tools support page
                  https://premier.intel.com/scripts-quad/welcomeplsb.asp
                  to get an account.

                  Ralph


                  ------------------

                  Comment


                  • #10
                    Ralph, I think I got it working in PB. Here is what I am using. I rewrote the routine
                    a little to mimic the VB sample provided with ijl15.dll. You had one obvious mistake
                    in the JPEG_CORE_PROPERTIES_VB type. The DIBHEIGHT should be a long or DWORD,
                    not an integer. Please note that I changed the declarations for ijl15.dll

                    Jeff

                    Code:
                    '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                    ' constants and prototype for ijl15.dll
                    'Private Enum IJLERR
                    
                    ' The following "error" values indicate an "OK" condition.
                    %IJL_OK = 0
                    %IJL_INTERRUPT_OK = 1
                    %IJL_ROI_OK = 2
                    
                    %IJL_EXCEPTION_DETECTED = -1
                    %IJL_INVALID_ENCODER = -2
                    %IJL_UNSUPPORTED_SUBSAMPLING = -3
                    %IJL_UNSUPPORTED_BYTES_PER_PIXEL = -4
                    %IJL_MEMORY_ERROR = -5
                    %IJL_BAD_HUFFMAN_TABLE = -6
                    %IJL_BAD_QUANT_TABLE = -7
                    %IJL_INVALID_JPEG_PROPERTIES = -8
                    %IJL_ERR_FILECLOSE = -9
                    %IJL_INVALID_FILENAME = -10
                    %IJL_ERROR_EOF = -11
                    %IJL_PROG_NOT_SUPPORTED = -12
                    %IJL_ERR_NOT_JPEG = -13
                    %IJL_ERR_COMP = -14
                    %IJL_ERR_SOF = -15
                    %IJL_ERR_DNL = -16
                    %IJL_ERR_NO_HUF = -17
                    %IJL_ERR_NO_QUAN = -18
                    %IJL_ERR_NO_FRAME = -19
                    %IJL_ERR_MULT_FRAME = -20
                    %IJL_ERR_DATA = -21
                    %IJL_ERR_NO_IMAGE = -22
                    %IJL_FILE_ERROR = -23
                    %IJL_INTERNAL_ERROR = -24
                    %IJL_BAD_RST_MARKER = -25
                    %IJL_THUMBNAIL_DIB_TOO_SMALL = -26
                    %IJL_THUMBNAIL_DIB_WRONG_COLOR = -27
                    %IJL_RESERVED = -99
                    
                    'END Enum
                    
                    'Private Enum IJLIOTYPE
                    %IJL_SETUP = -1&
                    ''// Read JPEG parameters (i.e., height, width, channels,
                    '' sampling, etc.) from a JPEG bit stream.
                    %IJL_JFILE_READPARAMS      = 0&
                    %IJL_JBUFF_READPARAMS      = 1&
                    '' Read a JPEG Interchange Format image.
                    %IJL_JFILE_READWHOLEIMAGE  = 2&
                    %IJL_JBUFF_READWHOLEIMAGE  = 3&
                    '' Read JPEG tables from a JPEG Abbreviated Format bit stream.
                    %IJL_JFILE_READHEADER      = 4&
                    %IJL_JBUFF_READHEADER      = 5&
                    '' Read image info from a JPEG Abbreviated Format bit stream.
                    %IJL_JFILE_READENTROPY     = 6&
                    %IJL_JBUFF_READENTROPY     = 7&
                    '' Write an entire JFIF bit stream.
                    %IJL_JFILE_WRITEWHOLEIMAGE = 8&
                    %IJL_JBUFF_WRITEWHOLEIMAGE = 9&
                    '' Write a JPEG Abbreviated Format bit stream.
                    %IJL_JFILE_WRITEHEADER     = 10&
                    %IJL_JBUFF_WRITEHEADER     = 11&
                    '' Write image info to a JPEG Abbreviated Format bit stream.
                    %IJL_JFILE_WRITEENTROPY    = 12&
                    %IJL_JBUFF_WRITEENTROPY    = 13&
                    '' Scaled Decoding Options:
                    '' Reads a JPEG image scaled to 1/2 size.
                    %IJL_JFILE_READONEHALF     = 14&
                    %IJL_JBUFF_READONEHALF     = 15&
                    '' Reads a JPEG image scaled to 1/4 size.
                    %IJL_JFILE_READONEQUARTER  = 16&
                    %IJL_JBUFF_READONEQUARTER  = 17&
                    '' Reads a JPEG image scaled to 1/8 size.
                    %IJL_JFILE_READONEEIGHTH   = 18&
                    %IJL_JBUFF_READONEEIGHTH   = 19&
                    '' Reads an embedded thumbnail from a JFIF bit stream.
                    %IJL_JFILE_READTHUMBNAIL   = 20&
                    %IJL_JBUFF_READTHUMBNAIL   = 21&
                    
                    'END Enum
                    
                    ' %IJL_BGR       = 24
                    %IJL_NONE       = 28
                    
                    %IJL_RGB        = 1  '' Red-Green-Blue COLOR space.
                    %IJL_BGR        = 2  '' Reversed channel ordering FROM IJL_RGB.
                    %IJL_YCBCR      = 3  '' Luminance-Chrominance COLOR space AS defined
                                         '' by CCIR Recommendation 601.
                    %IJL_G          = 4  '' Grayscale COLOR space.
                    %IJL_RGBA_FPX   = 5  '' FlashPix RGB 4 channel COLOR space that
                                         '' has pre-multiplied opacity.
                    %IJL_YCBCRA_FPX = 6  '' FlashPix YCbCr 4 channel COLOR space that
                                         '' has pre-multiplied opacity.
                    %IJL_411        = 1  '' Valid ON a JPEG w/ 3 channels.
                    %IJL_422        = 2  '' Valid ON a JPEG w/ 3 channels.
                    %IJL_4114       = 3  '' Valid ON a JPEG w/ 4 channels.
                    %IJL_4224       = 4  '' Valid ON a JPEG w/ 4 channels.
                    
                    TYPE JPEG_CORE_PROPERTIES_VB
                      UseJPEGPROPERTIES AS DWORD         ' default = 0
                    
                      ' DIB specific I/O data specifiers.
                      DIBBytes AS LONG                   ' default = NULL 4
                      DIBWidth AS LONG                   ' default = 0 8
                      DIBHeight AS LONG                  ' default = 0 12
                      DIBPadBytes AS LONG                ' default = 0 16
                      DIBChannels AS LONG                ' default = 3 20
                      DIBColor AS LONG                   ' default = IJL_BGR 24     enum
                      DIBSubsampling AS LONG             ' default = IJL_NONE 28    enum
                    
                      ' JPEG specific I/O data specifiers.
                      JPGFile AS LONG                    ' JPGFile; 32   '// default = NULL
                      JPGBytes AS LONG                   ' default = NULL 36
                      JPGSizeBytes AS LONG               ' default = 0 40
                      JPGWidth AS LONG                   ' default = 0 44
                      JPGHeight AS LONG                  ' default = 0 48
                      JPGChannels AS LONG                ' default = 3
                      JPGColor AS LONG                   ' default = IJL_YCBCR     enum
                      JPGSubsampling AS LONG             ' default = IJL_411       enum
                      JPGThumbWidth AS LONG              ' default = 0
                      JPGThumbHeight AS LONG             ' default = 0
                    
                      ' JPEG conversion properties.
                      cconversion_reqd AS LONG           ' default = TRUE
                      upsampling_reqd AS LONG            ' default = TRUE
                      jquality AS LONG                   ' default = 75.  100 is my preferred quality setting.
                    
                      Pad(0 TO 3) AS BYTE                ' 8-byte alignment!!!
                      jprops (0 TO 19999) AS BYTE
                    
                    END TYPE
                    
                    DECLARE FUNCTION ijlInit LIB "ijl15.dll" ALIAS "ijlInit" (BYVAL jcprops AS LONG) AS INTEGER
                    DECLARE FUNCTION ijlFree LIB "ijl15.dll" ALIAS "ijlFree" (BYVAL jcprops AS LONG) AS INTEGER
                    DECLARE FUNCTION ijlRead LIB "ijl15.dll" ALIAS "ijlRead" (BYVAL jcprops AS LONG, BYVAL ioType AS INTEGER) AS INTEGER
                    DECLARE FUNCTION ijlWrite LIB "ijl15.dll" ALIAS"ijlWrite" (BYVAL jcprops AS LONG , BYVAL ioType AS LONG) AS LONG
                    DECLARE FUNCTION ijlGetLibVersion LIB "ijl15.dll" ALIAS "ijlGetLibVersion" () AS LONG
                    DECLARE FUNCTION ijlGetErrorString LIB "ijl15.dll" ALIAS "ijlGetErrorString" (BYVAL code AS LONG) AS LONG
                    
                    
                    FUNCTION SaveJPG( infile AS ASCIIZ, sFile AS ASCIIZ, BYVAL lQuality AS LONG ) AS INTEGER
                        LOCAL tJ        AS JPEG_CORE_PROPERTIES_VB
                        LOCAL hBmp      AS LONG
                        LOCAL lPtr      AS LONG
                        LOCAL lR        AS LONG
                        LOCAL fh        AS LONG
                        LOCAL bmi       AS BITMAPINFO
                        LOCAL bm        AS bitmap
                        LOCAL hdc       AS LONG
                        LOCAL hdcmem    AS LONG
                        LOCAL pixelbuf  AS STRING
                        LOCAL hDesktop  AS LONG
                        LOCAL bmSize    AS LONG
                        LOCAL M_hDIB    AS LONG
                        LOCAL hBMPOld   AS LONG
                        LOCAL IJL_DIB_ALIGN AS LONG
                        LOCAL IJL_DIB_UWIDTH AS LONG
                        LOCAL IJL_DIB_AWIDTH AS LONG
                        
                        hBmp  = LoadImage(BYVAL %NULL, infile, %IMAGE_BITMAP,  0 , 0, %LR_CREATEDIBSECTION OR %LR_LOADFROMFILE )
                        IF hBmp = 0 THEN
                          MSGBOX "cannot read bmp"
                          FUNCTION = %false
                          EXIT FUNCTION
                        END IF
                        hDesktop = GetDesktopWindow()
                        hdc      = GetDC( hDesktop )
                        hdcmem   = CreateCompatibleDC(hdc)
                        ReleaseDC hDesktop, hdc
                        hdc= hdcmem
                        bmi.bmiHeader.biSize = LEN(bmi.bmiHeader)
                        CALL GetDIBits(hdc, hBmp, 0, 0,BYVAL 0, bmi, %DIB_RGB_COLORS)
                        ' make 24 bpp dib section
                        bmi.bmiHeader.biBitCount = 24
                        bmi.bmiHeader.biCompression = %BI_RGB
                        bmi.bmiHeader.biClrUsed = 0
                        bmi.bmiHeader.biClrImportant = 0
                        m_hDib = CreateDIBSection(hDC,bmi, %DIB_RGB_COLORS,VARPTR(lPtr), 0, 0)
                        IF m_hDib = 0 THEN
                          CALL DeleteObject(hBmp)
                          CALL DeleteObject(hDC)
                          hDC = 0
                          EXIT FUNCTION
                        END IF
                        hBmpOld = SelectObject(hDC, m_hDib)
                        bmi.bmiHeader.biSize = SIZEOF(bmi.bmiHeader)
                        ' get image data in 24 bpp format (convert if need)
                        CALL GetDIBits(hDC, hBmp, 0, bmi.bmiHeader.biHeight,BYVAL lPtr,bmi, %DIB_RGB_COLORS)
                        IF (lptr= 0) THEN
                          MSGBOX "Failed to Get DI Bits"
                          FUNCTION = %false
                          deleteObject hBmp
                          deletedc hdcmem
                        END IF
                        lR = ijlInit( VARPTR(tJ) )
                        IF lR <> %IJL_OK THEN
                          MSGBOX "Failed to init IJL"
                          FUNCTION = %false
                          deleteObject hBmp
                          deletedc hdcmem
                          EXIT FUNCTION
                        END IF
                        ' Set up the DIB information:
                        tJ.DIBWidth    = bmI.bmiHeader.biWidth
                        tJ.DIBHeight   = -bmI.bmiHeader.biHeight
                        tJ.DIBBytes    = lptr
                        tj.DIBChannels = bmi.bmiHeader.biBitCount / 8
                        IJL_DIB_ALIGN = 3
                        IJL_DIB_UWIDTH = tj.DIBChannels* bmi.bmiHeader.biWidth
                        IJL_DIB_AWIDTH = (IJL_DIB_UWIDTH + IJL_DIB_ALIGN) AND (NOT (IJL_DIB_ALIGN))
                        tJ.DIBPadBytes = IJL_DIB_AWIDTH - IJL_DIB_UWIDTH
                        MSGBOX STR$(SIZEOF(tj))
                        ' Set up the JPEG information:
                        IF tj.DIBChannels = 3 THEN
                          tj.DIBColor = %IJL_BGR
                          tj.JPGColor = %IJL_YCBCR
                          tj.JPGChannels = 3
                          tj.JPGSubsampling = %IJL_411
                          ELSE
                            tj.DIBColor = %IJL_RGBA_FPX
                            tj.JPGColor = %IJL_YCBCRA_FPX
                            tj.JPGChannels = 4
                            tj.JPGSubsampling = %IJL_4114
                        END IF
                        tJ.JPGFile     = VARPTR(sfile)
                        tJ.JPGWidth    = bmi.bmiHeader.biWidth
                        tJ.JPGHeight   = bmi.bmiHeader.biHeight
                        tJ.jquality    = 75   '' lQuality
                        ' Write the image:
                        lR = ijlWrite(VARPTR(tJ), %IJL_JFILE_WRITEWHOLEIMAGE)
                        IF lR = %IJL_OK THEN
                           FUNCTION = %True
                        ELSE
                           MSGBOX "Failed to save to JPG " + STR$(lr)
                        END IF
                        deleteObject hBmp
                        deletedc hdcmem
                        ' Ensure we have freed memory:
                        ijlFree VARPTR(tJ)
                    END FUNCTION
                    
                    
                    FUNCTION PBMAIN()
                      SaveJPG BYVAL strptr(bmp$),BYVAL STRPTR(jpg$), 100
                    
                    END FUNCTION

                    ------------------

                    Comment


                    • #11
                      Originally posted by Ralph Berger:
                      seems we are doing the same thing at the same time.
                      Don't know, what are you doing, but I want to construct add-on for main program with following functions:
                      1) Download (update) from Internet the actual base of scanned documents (de-facto, black-white).
                      2) Allow to view and print.

                      Documents should be in "unknown" format for Imagine or to another program (I plan to "decrypt" in memory).
                      JPG or TIFF is not important. Mainly - compact.


                      Jeffrey --
                      I tested your sub on some samples under Win2000.
                      It works. Thanx.
                      ------------------
                      E-MAIL: [email protected]

                      [This message has been edited by Semen Matusovski (edited January 15, 2001).]

                      Comment


                      • #12
                        What about a function to convert JPG images to BMP?

                        ------------------
                        Thanks,

                        Doug Gamble
                        mailto:[email protected][email protected]</A>
                        Thanks,

                        Doug Gamble
                        [email protected]

                        Comment


                        • #13
                          Doug, the process is similar. Here is the code I wrote. The only caveat is
                          saving the bitmap file. I use my own routines for memory block handling.
                          I've converted what I can. Basically when you load a JPG using the IJL, it
                          converts it to a standard DIB section. Then you save the memory DIB to a file.


                          Jeff

                          Code:
                          FUNCTION JPGtoBMP SDECL ALIAS "JPGtoBMP"(bmp$, sfile$, BYVAL jpg_scale AS LONG) EXPORT AS LONG
                            LOCAL jerr AS LONG
                            LOCAL jcprops AS JPEG_CORE_PROPERTIES_VB
                            LOCAL aFile AS STRING
                            LOCAL lJPGWidth AS LONG
                            LOCAL lJPGHeight AS LONG
                            LOCAL nChannels AS LONG
                            LOCAL hdc AS LONG, hDIB AS LONG, hbmpold AS LONG
                            LOCAL bmi AS BITMAPINFO
                            LOCAL lptr AS LONG
                            LOCAL IJL_DIB_ALIGN AS LONG
                            LOCAL IJL_DIB_UWIDTH AS LONG
                            LOCAL IJL_DIB_AWIDTH AS LONG
                            LOCAL mem&,fmem&,path$
                            LOCAL bfh AS BITMAPFILEHEADER
                            jerr = ijlInit(VARPTR(jcprops))
                            IF jerr = %IJL_OK THEN
                              jcprops.JPGFile = STRPTR(sFile$)
                              jerr = ijlRead(VARPTR(jcprops), %IJL_JFILE_READPARAMS)
                              IF jerr <> %IJL_OK THEN
                                'MSGBOX "Error Reading JPG File ....",,"Import Error"
                                FUNCTION= 0
                                EXIT FUNCTION
                              END IF
                              lJPGWidth = jcprops.JPGWidth
                              lJPGHeight = jcprops.JPGHeight
                              SELECT CASE jpg_scale
                                CASE= 1
                                CASE= 2
                                  lJPGWidth = (lJPGWidth + 1) / 2
                                  lJPGHeight = (lJPGHeight + 1) / 2
                                CASE= 4
                                  lJPGWidth = (lJPGWidth + 3) / 4
                                  lJPGHeight = (lJPGHeight + 3) / 4
                                CASE 8
                                  lJPGWidth = (lJPGWidth + 7) / 8
                                  lJPGHeight = (lJPGHeight + 7) / 8
                              END SELECT
                              IF jcprops.JPGChannels = 1 THEN
                                jcprops.JPGColor = %IJL_G
                                jcprops.DIBColor = %IJL_BGR
                                nChannels = 3
                                ELSEIF jcprops.JPGChannels = 3 THEN
                                  jcprops.JPGColor = %IJL_YCBCR
                                  jcprops.DIBColor = %IJL_BGR
                                  nChannels = 3
                                  ELSEIF jcprops.JPGChannels = 4 THEN
                                    jcprops.JPGColor = %IJL_YCBCRA_FPX
                                    jcprops.DIBColor = %IJL_RGBA_FPX
                                    nChannels = 4
                              END IF
                              hDC = CreateCompatibleDC(0)
                              IF (hDC <> 0) THEN
                                bmi.bmiHeader.biSize = LEN(bmi.bmiHeader)
                                bmi.bmiHeader.biWidth = lJPGWidth
                                bmi.bmiHeader.biHeight = lJPGHeight
                                bmi.bmiHeader.biPlanes = 1
                                IF nChannels = 3 THEN
                                  bmi.bmiHeader.biBitCount = 24
                                  ELSE
                                    bmi.bmiHeader.biBitCount = 32
                                END IF
                                bmi.bmiHeader.biCompression = %BI_RGB
                                bmi.bmiHeader.biSizeImage = ((bmi.bmiHeader.biWidth * (bmi.bmiHeader.biBitCount / 8) + 3) AND &HFFFFFFFC) * bmi.bmiHeader.biHeight
                                hDib = CreateDIBSection(hDC,bmi,%DIB_RGB_COLORS,VARPTR(lPtr), 0, 0)
                                IF (hDib= 0) THEN
                                  MSGBOX "Error Creating DIB .....",,"Import Error"
                                  FUNCTION= 0
                                  deletedc hdc
                                  jerr = ijlFree(VARPTR(jcprops))
                                  EXIT FUNCTION
                                END IF
                                hBmpOld = SelectObject(hDC,hDib)
                                ELSE
                                  FUNCTION = 0
                                  deletedc hdc
                                  jerr = ijlFree(VARPTR(jcprops))
                                  EXIT FUNCTION
                              END IF
                              jcprops.DIBWidth = lJPGWidth
                              jcprops.DIBHeight = -lJPGHeight
                              jcprops.DIBChannels = nChannels
                              jcprops.DIBBytes = lptr
                              IJL_DIB_ALIGN = 3
                              IJL_DIB_UWIDTH = jcprops.DIBWidth * jcprops.DIBChannels
                              IJL_DIB_AWIDTH = (IJL_DIB_UWIDTH + IJL_DIB_ALIGN) AND (NOT (IJL_DIB_ALIGN))
                              jcprops.DIBPadBytes = IJL_DIB_AWIDTH - IJL_DIB_UWIDTH
                              SELECT CASE jpg_scale
                                CASE 1
                                  ' Now decompress the JPG into the DIBSection:
                                  jerr = ijlRead(VARPTR(jcprops), %IJL_JFILE_READWHOLEIMAGE)
                                CASE 2
                                  ' Now decompress the JPG into the DIBSection:
                                  jerr = ijlRead(VARPTR(jcprops), %IJL_JFILE_READONEHALF)
                                CASE 4
                                  ' Now decompress the JPG into the DIBSection:
                                  jerr = ijlRead(VARPTR(jcprops), %IJL_JFILE_READONEQUARTER)
                                CASE 8
                                  ' Now decompress the JPG into the DIBSection:
                                  jerr = ijlRead(VARPTR(jcprops), %IJL_JFILE_READONEEIGHTH)
                              END SELECT
                              IF jerr = %IJL_OK THEN
                                'This is the process of saving a BMP file from a DIB Section
                                mem&= GlobalAlloc(%GMEM_FIXED,bmi.bmiHeader.biSizeImage)
                                di&= GetDIBits(hDC&,hdib,0,lJPGHeight,BYVAL mem&,bmi,%DIB_RGB_COLORS)
                                bfh.bfType= CVWRD("BM")
                                bfh.bfSize = SIZEOF(bfh) + SIZEOF(bmi) + bmi.bmiHeader.biSizeImage
                                bfh.bfOffBits = SIZEOF(bfh) + SIZEOF(bmi)
                                fmem&= Globalalloc(%GMEM_FIXED,bfh.bfsize)
                                'Copy Bitmap File Header
                                CopyMemory fmem&,VARPTR(bfh),SIZEOF(bfh)
                                'Copy BitmapInfo Structure 
                                CopyMemory fmem&+SIZEOF(bfh),VARPTR(bmi),LEN(bmi)
                                'Copy DIB Bits
                                CopyMemory fmem&+SIZEOF(bfh)+SIZEOF(bmi),mem&,bmi.bmiHeader.biSizeImage
                                'Save mem block to file.  This function is my own routine.  You can
                                'easily use the PB Open as Binary function also.
                                SaveMemtoFile bmp$,fmem&,bfh.bfsize
                                di&= GlobalFree(mem&)
                                di&= GlobalFree(fmem&)
                                'Now you have the original JPG file saved as a separate BMP.
                                ELSE
                                  MSGBOX "Error Reading Image Data ......",,"Import Error"
                                  FUNCTION= 0
                                  EXIT FUNCTION
                              END IF
                              jerr = ijlFree(VARPTR(jcprops))
                              ELSE
                                MSGBOX "Failed to init JPG dll",,"Import Error"
                                FUNCTION= 0
                                EXIT FUNCTION
                            END IF
                            FUNCTION= 1
                            deleteObject hDIB
                            deletedc hdc
                          END FUNCTION
                          ------------------


                          [This message has been edited by Jeffrey R. Radue (edited January 15, 2001).]

                          Comment


                          • #14
                            I cannot get the JPGtoBMP function to work. It is generating an
                            error when it is loading the JPG file (I uncommented the MsgBox).

                            Any ideas?


                            ------------------
                            Thanks,

                            Doug Gamble
                            mailto:[email protected][email protected]</A>
                            Thanks,

                            Doug Gamble
                            [email protected]

                            Comment


                            • #15
                              Doug, why don't you post the code you are using and I'll see if I can find the problem.
                              The routine I posted works fine for me (Win 2k).

                              Jeff

                              P.S. Did you copy all the equates and types from the first function?
                              ------------------


                              [This message has been edited by Jeffrey R. Radue (edited January 16, 2001).]

                              Comment


                              • #16
                                I'm using the code you posted (I even cut and pasted it again)
                                and the equates and function posted by Ralph Berger at the start
                                of this thread. Could there be a difference between the equates
                                and DLL defines you are using and the ones Ralph posted? Could
                                you also post your SaveMemToFile function? Perhaps you could
                                post or email the actual BAS and INC code you are using to test
                                your routine. I am also using Win2K.


                                ------------------
                                Thanks,

                                Doug Gamble
                                mailto:[email protected][email protected]</A>
                                Thanks,

                                Doug Gamble
                                [email protected]

                                Comment


                                • #17
                                  I figured out part of it...

                                  I was passing the BMP file name where the JPG file name should
                                  have been (Duh!!!). Once I corrected this the error goes away,
                                  but I still don't get the BMP file save correctly. I think the
                                  problem is the routine I'm using to save the memory data to the
                                  disk file. Jeff could you please post the code for your
                                  SaveMemToFile function? I replaced your CopyMemory function with
                                  the MoveMemory API but if you think this could be a problem let
                                  me know.

                                  ------------------
                                  Thanks,

                                  Doug Gamble
                                  mailto:[email protected][email protected]</A>
                                  Thanks,

                                  Doug Gamble
                                  [email protected]

                                  Comment


                                  • #18
                                    Now it works...

                                    There was a problem in the routine I was using to save the memory
                                    to the BMP file. How about displaying the converted JPG as a
                                    BMP in a PictureBox without saving it as a BMP first? Or to put
                                    it a different way how to display a DIB from memory in a standard
                                    PictureBox?



                                    ------------------
                                    Thanks,

                                    Doug Gamble
                                    mailto:[email protected][email protected]</A>
                                    Thanks,

                                    Doug Gamble
                                    [email protected]

                                    Comment


                                    • #19
                                      Doug, I can post the code to do that but, it appears you should take some
                                      time to review using raster image operations in Windows. I spent countless hours
                                      studying MS knowledge base code (and the like) before the the light bulb
                                      went on. I personally have a real problem blindly using other developers code
                                      in my programs. It makes it impossible to debug or modify if you don't know how the code
                                      was constructed. Besides, you'll never learn anything.

                                      Anyway, after voicing my opinion, here are the steps you need to take. Since I don't know your
                                      exact situation, these are general steps only:

                                      1. Load the BMP file using the LoadImage function. This gives you a handle to
                                      the bitmap.
                                      2. Create a compatible DC to the image control or Window you are drawing to.

                                      3. Select the bitmap handle into the compatible DC.

                                      4. Use the BltBit, StretchBlt, etc. to draw the image into the Window DC from the
                                      compatible DC.

                                      This should only take about 10 lines of code at most. And there are numerous examples of simple
                                      bitmap manipulation on the PB forum.

                                      Good Luck, and let me know how it works out!

                                      Jeff

                                      Sorry kind'a misread your message. Once you create the DIB, you have BMP handle
                                      that you can use for the above process.

                                      ------------------


                                      [This message has been edited by Jeffrey R. Radue (edited January 16, 2001).]

                                      Comment


                                      • #20
                                        Jeffrey --
                                        I don't know about ijl110, but for ijl115 jprops (0 TO 19999) AS BYTE is not enough
                                        (I tested by Len in VB).
                                        Plus, as I understand, in "declare" for functions should be long (according the same VB LEN).
                                        Yesterday I made full conversion of ijl.bas (1 : 1) + some functions (Load/Save Bmp/Jpg).
                                        Test samples work, but I need to re-check "by eyes".



                                        ------------------
                                        E-MAIL: [email protected]

                                        Comment

                                        Working...
                                        X