bmp를 vb6에서 jpg로 변환하는 방법은 무엇입니까?bbmp를 jpg로 변환하는 방법
8
A
답변
3
확인이 link
'Convert BMP to JPG with this code. (Note: Requires vic32.dll available from
'http://www.catenary.com/)
'PLACE ALL THIS IN A NEW MODULE
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
End Sub
+0
VIC32.DLL은 약 250kb입니다. Victor Library 가격은 $ 499이며 배포료는 없습니다. –
1
From here: 다른 형식으로 파일을 저장 사용할 수있는 다양한 타사 컨트롤이는 종종 '좌석 당'받아 들일 수있는 라이선스 정책과 믿을 수 없을만큼 될 수 있습니다 동안
비싼. 이 기사에서는 무료 JPEG DLL 라이브러리를 사용하여 VB 사진을 저장하는 방법을 보여줍니다. PS
: 그냥 JPG 이미지를 저장하기위한 VIC32 같은 라이브러리 $ 500 지불하는 것은 너무 많은 것 같다 ...
2
은 ImageMagick 우주선을하고 무언가 같은
shell "convert.exe image.bmp image.jpg"
2
3
XP SP1 이상에서는 제공된 도구 인 WIA 2.0 라이브러리를 사용할 수 있습니다. 당신이해야합니다 XP의
Option Explicit
'
'Requires a reference to:
' Microsoft Windows Image Acquisition Library v2.0
'
Private Const TIFF_LZW As String = "LZW"
Private Const TIFF_RLE As String = "RLE" 'Pixel Depth must be 1.
Private Const TIFF_CCITT3 As String = "CCITT3" 'Pixel Depth must be 1.
Private Const TIFF_CCITT4 As String = "CCITT4" 'Pixel Depth must be 1.
Private Const TIFF_Uncompressed As String = "Uncompressed"
Private Sub ImgConvert(_
ByVal InFileName As String, _
ByVal OutFileName As String, _
ByVal OutFormat As String, _
Optional ByVal Quality As Integer = 100, _
Optional ByVal Compression As String = TIFF_LZW)
Dim Img As WIA.ImageFile
Dim ImgProc As WIA.ImageProcess
Set Img = New WIA.ImageFile
Img.LoadFile InFileName
Set ImgProc = New WIA.ImageProcess
With ImgProc.Filters
.Add ImgProc.FilterInfos("Convert").FilterID
.Item(1).Properties("FormatID").Value = OutFormat
If OutFormat = wiaFormatJPEG Then
.Item(1).Properties("Quality").Value = Quality
ElseIf OutFormat = wiaFormatTIFF Then
.Item(1).Properties("Compression").Value = Compression
End If
End With
Set Img = ImgProc.Apply(Img)
On Error Resume Next
Kill OutFileName
On Error GoTo 0
Img.SaveFile OutFileName
End Sub
Private Sub Main()
ImgConvert "sample.bmp", "sample.jpg", wiaFormatJPEG, 70
ImgConvert "sample.bmp", "sample.gif", wiaFormatGIF
ImgConvert "sample.bmp", "sample.png", wiaFormatPNG
ImgConvert "sample.bmp", "sample.tif", wiaFormatTIFF, , TIFF_Uncompressed
MsgBox "Complete"
End Sub
은 단순히 당신이 여기에 라인의 거의 절반을 제거 할 수 있습니다 JPG로 BMP로 변환합니다.
나중에 어떤 것이 든 그것은 이미 OS의 일부입니다.
2
간단히!
1)은 최단 방법 :
SavePicture(LoadPicture("c:\YourFile.BMP"),"c:\YourFile.JPG")
2) 당신이 어떤 형식 (와/압축없이)로 변환 할 경우에, 나는 FFMpeg을 추천합니다.
Shell("ffmpeg.exe -i YourFile.bmp -q <qualityNumber*> ConverTo.Any")
* write ffmpeg /? cmd 사용법을 알아야합니다
관련 문제
- 1. .net에서 jpg로 문서 변환하는 방법
- 2. .jpg로 이미지를 선택하는 방법
- 3. jpg로 문서를 인쇄하는 방법
- 4. JPG로 PHP/WinServer PDF
- 5. .eps를 .jpg로 변환
- 6. 비디오 형식을 코드 변환하는 방법
- 7. TIFF를 JPG로 변환하는 방법 Silverlight, 클라이언트 측, 컨트롤 또는 클래스/함수 사용
- 8. eps를 jpg로 변환하려면 어떻게해야합니까?
- 9. PHP에서 BMP를 JPG로 변환
- 10. PDF를 jpg로 변환 하시겠습니까?
- 11. Txt를 JPG로 변환
- 12. Android에서 RGB888로 JPG로 읽기
- 13. 캔버스를 jpg로 저장
- 14. PDF를 JPG로 자동 업로드 Drupal에서 업로드시
- 15. C#을 사용하여 BLOB를 Jpg로 변환
- 16. 변환하는 방법
- 17. 어떻게 PHP에서 PNG로 JPG로 변환합니까?
- 18. Image Magick이 svg 파일을 jpg로 변환하지 않았습니다.
- 19. PDF 첫 페이지 가져 오기 및 JPG로 변환
- 20. Node.js : 서버에 base64로 인코딩 된 이미지를 png/jpg로 저장하는 방법
- 21. 그림 상자에 사각형을 그리고 선택한 부분을 .jpg로 저장하는 방법
- 22. doe 무료 도구 나 rtf를 jpg로 변환하는 방법을 알고있는 분 누구입니까
- 23. GoDaddy와 같은 호스트에서 .doc 파일을 pdf 또는 jpg로 변환하는 방법이 있습니까?
- 24. px를 %로 변환하는 방법 (px를 글꼴 크기로 em로 변환하는 방법)
- 25. 프로젝트에서 파일을 변환하는 방법 - java에서 파일을 IFile로 변환하는 방법?
- 26. int를 통화로 변환하는 방법?
- 27. Excel을 XML로 변환하는 방법?
- 28. ActionScriptObject를 ByteArray로 변환하는 방법?
- 29. 영어를 Cron으로 변환하는 방법?
- 30. PUNICODE_STRING을 bstr으로 변환하는 방법?
BMP를 JPG에 대해 질문했기 때문에 정확히 중복되지는 않지만 [GIF를 JPG 또는 TIF로 변환] (http://stackoverflow.com/)에서이 질문에 관심이있을 수 있습니다. 질문/1333901/visual-basic-6-image-conversion-from-gif-to-jpg-or-tif) – MarkJ
http://www.vbaccelerator.com/home/VB/Code/vbMedia/Saving_Pictures_to_JPG/Using_Intel_JPG_Library/를 참조하십시오. 문제의 article.asp 언급 된 마크. –