Solution: Get black Image after saving a picture with Intel JPEG library 
Author Message
 Solution: Get black Image after saving a picture with Intel JPEG library

Hi,

if you have the problem, that the Intel JPEG Library produces a black image
after saving, the may this will help you:

Insert the following function into the cDIBSection.cls file:

Public Function GetImg(ByRef Img As Object) As Boolean
  Dim hBmp As Long

  CleanUp

  GetImg = False

  m_hDC = CreateCompatibleDC(0)
  If m_hDC = 0 Then
    Exit Function
  End If

  hBmp = CopyImage(Img.handle, IMAGE_BITMAP, 0, 0, (LR_CREATEDIBSECTION))
  If hBmp = 0 Then
    Call DeleteObject(m_hDC)
    m_hDC = 0
    MsgBox "Can't load BMP image"
    Exit Function
  End If

  m_bmi.bmiHeader.biSize = Len(m_bmi.bmiHeader)

  ' get image sizes
  Call GetDIBits(m_hDC, hBmp, 0, 0, 0, m_bmi, DIB_RGB_COLORS)

  ' make 24 bpp dib section
  m_bmi.bmiHeader.biBitCount = 24
  m_bmi.bmiHeader.biCompression = BI_RGB
  m_bmi.bmiHeader.biClrUsed = 0
  m_bmi.bmiHeader.biClrImportant = 0

  m_hDib = CreateDIBSection(m_hDC, m_bmi, DIB_RGB_COLORS, m_lPtr, 0, 0)
  If m_hDib = 0 Then
    Call DeleteObject(hBmp)
    Call DeleteObject(m_hDC)
    m_hDC = 0
    Exit Function
  End If

  m_hBmpOld = SelectObject(m_hDC, m_hDib)

  m_bmi.bmiHeader.biSize = Len(m_bmi.bmiHeader)

  ' get image data in 24 bpp format (convert if need)
  Call GetDIBits(m_hDC, hBmp, 0, m_bmi.bmiHeader.biHeight, m_lPtr, m_bmi,
DIB_RGB_COLORS)

  Call DeleteObject(hBmp)

  GetImg = True
End Function

Use it like this:

  dim cDIB as new cDIBSection
  cDIB.GetImg myForm.PictureBox.Image
  SaveJPEG cDIB, "C:\test.jpg"

After that, it works fine!

I.

--
__________________________________________________________
News suchen, lesen, schreiben mit http://www.*-*-*.com/



Fri, 07 Nov 2003 18:52:58 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Intel 1.1 Intel JPEG Library is FAST but...?

2. Save the image to TIFF,JPEG ,GIF,PNG,BMP solution

3. Intel Jpeg Library

4. Intel Jpeg Library

5. Alternative to Intel JPEG Library?

6. Alternative to Intel JPEG Library?

7. Intel JPEG library

8. JPEG - New version Intel Library

9. Intel Library - JPEG - How to ?

10. Intel Performance Libraries (Math/Image/Signal) in VB?

11. Intel's Image Processing Library

12. Image saving with Intel JPG

 

 
Powered by phpBB® Forum Software