哈哈,再来一个BMP 转 JPG 的模块,该有的都了。

原创 2007年10月15日 15:04:00

应朋友需要,把远程屏幕监控需要的核心代码发布 出来,这是最后一个,发送算法自己写咯

Option Explicit
Private Type GUID
    Data1  As Long
    Data2  As Integer
    Data3  As Integer
    Data4(0 To 7)    As Byte
End Type
Private Type GdiplusStartupInput
    GdiplusVersion  As Long
    DebugEventCallback  As Long
    SuppressBackgroundThread  As Long
    SuppressExternalCodecs  As Long
End Type
Private Type EncoderParameter
    GUID  As GUID
    NumberOfvalues  As Long
type  As Long
    value  As Long
End Type
Private Type EncoderParameters
    Count  As Long
    Parameter  As EncoderParameter
End Type
Private Declare Function GdiplusStartup Lib "GDIPlus" (token As Long, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As Long
Private Declare Function GdiplusShutdown Lib "GDIPlus" (ByVal token As Long) As Long
Private Declare Function GdipCreateBitmapFromHBITMAP Lib "GDIPlus" (ByVal hbm As Long, ByVal hpal As Long, Bitmap As Long) As Long
Private Declare Function GdipDisposeImage Lib "GDIPlus" (ByVal Image As Long) As Long
Private Declare Function GdipSaveImageToFile Lib "GDIPlus" (ByVal Image As Long, ByVal FileName As Long, clsidEncoder As GUID, encoderParams As Any) As Long
Private Declare Function CLSIDFromString Lib "ole32" (ByVal str As Long, id As GUID) As Long

'  ----====  SaveJPG  ====----

Public Sub SaveJPG(ByVal pict As StdPicture, ByVal FileName As String, Optional ByVal quality As Byte = 80)
    Dim tSI   As GdiplusStartupInput
    Dim lRes   As Long
    Dim lGDIP   As Long
    Dim lBitmap   As Long
    '  Initialize  GDI+
    tSI.GdiplusVersion = 1
    lRes = GdiplusStartup(lGDIP, tSI)
    If lRes = 0 Then
        '  Create  the  GDI+  bitmap
        '  from  the  image  handle
        lRes = GdipCreateBitmapFromHBITMAP(pict.Handle, 0, lBitmap)
        If lRes = 0 Then
            Dim tJpgEncoder   As GUID
            Dim tParams   As EncoderParameters
            '  Initialize  the  encoder  GUID
            CLSIDFromString StrPtr("{557CF401-1A04-11D3-9A73-0000F81EF32E}"), tJpgEncoder
            '  Initialize  the  encoder  parameters
            tParams.Count = 1
            With tParams.Parameter   '  Quality
                '  Set  the  Quality  GUID
                CLSIDFromString StrPtr("{1D5BE4B5-FA4A-452D-9CDD-5DB3505E7EB}"), .GUID
                .NumberOfvalues = 1
                .type = 1
                .value = VarPtr(quality)
            End With
            '  Save  the  image
            lRes = GdipSaveImageToFile(lBitmap, StrPtr(FileName), tJpgEncoder, tParams)
            '  Destroy  the  bitmap
            GdipDisposeImage lBitmap
        End If
        '  Shutdown  GDI+
        GdiplusShutdown lGDIP
    End If
    If lRes Then
      'Err.Raise 5, , "Cannot  save  the  image.  GDI+  Error:" & lRes
      GdiplusShutdown lGDIP
      lRes = GdiplusStartup(lGDIP, tSI)

  End If
End Sub

将YUYV图像转换为BMP图像的WINDOWS命令行程序

  • 2017年09月13日 19:00
  • 117KB
  • 下载

VC实现:bmp转jpg、jpg转bmp、截屏保存jpg

    1.下载(GDI+ for VC6.0 SDK)GDIPlus文件将其中的Includes和Lib中的文件拷到vc目录下的Includes和Lib文件夹中.   下载地址:http://w...
  • highyyy
  • highyyy
  • 2011-01-09 21:25:00
  • 5589

C 实现BMP 转换为JPG 附源代码

基本思路:利用开源库libjpeg实现将bmp图像转换为jpeg图像,并可以设置jpeg压缩的质量因子。 实验注意事项: 1:bmp数据存储时是按照BGR顺序。 2:biHeight为正数时表示...
  • Konae
  • Konae
  • 2012-07-23 16:23:28
  • 3404

BMP转JPG(法一)使用jpeglib库实现bmp转jpg

一、vc编译jpeglib库 1、下载源代码 下载地址:http://www.ijg.org/。注意:一定要下载win32 版本 2、编译源代码.     A、解压源代码,修改源代码中jcon...
  • chenyujing1234
  • chenyujing1234
  • 2012-07-11 15:03:07
  • 9400

C++ BMP转JPG方法三

因为最近涉及将大的jpg缩小后再在网络上传输,所以需要将大的jpg转小的JPG。首先用Opencv将jpg读取到内存,缩小后,保存为bmp,再将bmp转JPG。如果直接是bmp文件也可以的。7万张图片...
  • sz76211822
  • sz76211822
  • 2017-04-19 16:16:33
  • 2064

VC 实现BMP转换到JPG、JPG转换到BMP

int GetEncoderClsid(const WCHAR* format, CLSID* pClsid) { UINT num = 0; ...
  • lu1012123053
  • lu1012123053
  • 2012-12-07 15:37:51
  • 9901

C#BMP文件转JPG例程

在.NET平台上,使用C#语言可以方便的将BMP文件转化为JPG文件,转换方法如下:          string BMPFiles = “D://BMP//qq.bmp”         //BM...
  • flywithmj
  • flywithmj
  • 2011-06-16 15:54:00
  • 5214

delphi bmp转jpg

procedure BMPToJPG(BmpFileName:string);var  Jpeg : TJPEGImage;  Bmp : TBitmap;begin  Bmp := TBitmap....
  • xwchen
  • xwchen
  • 2007-09-12 20:38:00
  • 3409

Java 图片格式转换(包括bmp-->jpg)

java在做图片类型转换时,JDK本身提供的类对   GIF->JPG GIF->PNG PNG->GIF(X) PNG->JPG 这几种类型的转换支持比较好,可以通过类直接转,代码如下:/** ...
  • shixing_11
  • shixing_11
  • 2010-07-13 10:29:00
  • 13536

jpg批量转换成bmp工具

  • 2010年02月01日 14:35
  • 48KB
  • 下载
收藏助手
不良信息举报
您举报文章:哈哈,再来一个BMP 转 JPG 的模块,该有的都了。
举报原因:
原因补充:

(最多只允许输入30个字)