| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1739 人关注过本帖
标题:[转载]VB实现图片文件格式的转换````
只看楼主 加入收藏
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
 问题点数:0 回复次数:2 
[转载]VB实现图片文件格式的转换````
Option Explicit
'============VB中实现BMP > GIF>JPG========================
Private Type RGBTRIPLE
rgbRed As Byte
rgbGreen As Byte
rgbBlue As Byte
End Type

Private Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type

Private Type BITMAPINFOHEADER '40 bytes
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

Private Type BITMAPINFO256
bmiHeader As BITMAPINFOHEADER
bmiColors(0 To 255) As RGBQUAD
End Type

Private Type BITMAP '14 bytes
bmType As Long
bmWidth As Long
bmHeight As Long
bmWidthBytes As Long
bmPlanes As Integer
bmBitsPixel As Integer
bmBits As Long
End Type

Private Const BI_RGB = 0&

Private Declare Function CreateDCAsNull Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, lpDeviceName As Any, lpOutput As Any, lpInitData As Any) As Long
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hDc As Long) As Long
Private Declare Function GetObjectAPI Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hDc As Long, ByVal hObject As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hDc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO256, ByVal wUsage As Long) As Long
Private Declare Function CreateDIBSection256 Lib "gdi32" Alias "CreateDIBSection" (ByVal hDc As Long, pBitmapInfo As BITMAPINFO256, ByVal un As Long, lplpVoid As Long, ByVal handle As Long, ByVal dw As Long) As Long
Private Const DIB_RGB_COLORS = 0

Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
'============================GIF STAFF================

Private Type GifScreenDes criptor
logical_screen_width As Integer
logical_screen_height As Integer
flags As Byte
background_color_index As Byte
pixel_aspect_ratio As Byte
End Type

Private Type GifImageDes criptor
Left As Integer
Top As Integer
Width As Integer
Height As Integer
Format As Byte 'ImageFormat
End Type

Const GIF87a = "GIF87a"
Const GifTerminator As Byte = &H3B
Const ImageSeparator As Byte = &H2C
Const CHAR_BIT = 8
Const CodeSize As Byte = 9
Const ClearCode = 256
Const EndCode As Integer = 257
Const FirstCode = 258
Const LastCode As Integer = 511
Const MAX_CODE = LastCode - FirstCode

Private colTable As New Collection
Private fn As Integer
Private gifPalette(0 To 255) As RGBTRIPLE
Private bit_position As Integer
Private code_count As Integer
Private data_buffer(255) As Byte
Private aPower2(31) As Long
Private picWidth As Long, picHeight As Long
Private IsBusy As Boolean
Public Event Progress(ByVal Percents As Integer)

Public Function SaveGIF(ByVal pic As StdPicture, ByVal sFileName As String, Optional hDc As Long = 0) As Boolean
If IsBusy Then Exit Function
Dim scr As GifScreenDes criptor, im As GifImageDes criptor
Dim bi As BITMAPINFO256, bm As BITMAP
Dim hDCScn As Long, OldObj As Long, Src_hDc As Long
Dim hDib256 As Long, hDC256 As Long, OldObj256 As Long
Dim buf() As Byte, data As Byte
Dim I As Long, J As Long
Dim intCode As Integer, nCount As Integer
Dim sPrefix As String, sByte As String
Dim tempPic As StdPicture
IsBusy = True
'get image size and allocate buffer memory
Call GetObjectAPI(pic, Len(bm), bm)
picWidth = bm.bmWidth
picHeight = bm.bmHeight
ReDim buf(CLng(((picWidth + 3) \ 4) * 4), picHeight) As Byte
'Prepare DC for paintings
hDCScn = CreateDCAsNull("DISPLAY", ByVal 0&, ByVal 0&, ByVal 0&)
hDC256 = CreateCompatibleDC(hDCScn)
If hDc = 0 Then
Src_hDc = CreateCompatibleDC(hDCScn)
OldObj = SelectObject(Src_hDc, pic)
Else
Src_hDc = hDc
End If
DeleteDC hDCScn

'Since GIF works only with 256 colors, reduce color depth to 256
'This sample use simpliest HalfTone palette to reduce color depth
'If you want advanced color manipulation with web-safe palettes or
'optimal palette with the specified number of colors using octree
'quantisation, visit http://vbaccelerator.com/codelib/gfx/octree.htm

If bm.bmBitsPixel <> 8 Then hDib256 = CreateDib256(hDC256, bi)
If hDib256 <> 0 Then
OldObj256 = SelectObject(hDC256, hDib256)
Call BitBlt(hDC256, 0, 0, picWidth, picHeight, Src_hDc, 0, 0, vbSrcCopy)
For I = 0 To picHeight - 1
Call GetDIBits(hDC256, hDib256, I, 1, buf(0, picHeight - I), bi, 0)
Next
Else
With bi.bmiHeader
.biSize = Len(bi.bmiHeader)
.biWidth = picWidth
.biHeight = picHeight
.biPlanes = 1
.biBitCount = 8
.biCompression = BI_RGB
End With
For I = 0 To picHeight - 1
Call GetDIBits(Src_hDc, pic, I, 1, buf(0, picHeight - I), bi, 0)
Next
End If
For I = 0 To 255
gifPalette(I).rgbBlue = bi.bmiColors(I).rgbBlue
gifPalette(I).rgbGreen = bi.bmiColors(I).rgbGreen
gifPalette(I).rgbRed = bi.bmiColors(I).rgbRed
Next
fn = FreeFile
scr.background_color_index = 0
scr.flags = &HF7 '256-color gif with global color map
scr.pixel_aspect_ratio = 0

im.Format = &H7 'GlobalNonInterlaced
im.Height = picHeight
im.Width = picWidth

If FileExists(sFileName) Then Kill sFileName

Open sFileName For Binary As fn
'Write GIF header and header info
Put #fn, , GIF87a
Put #fn, , scr
Put #fn, , gifPalette
Put #fn, , ImageSeparator
Put #fn, , im
data = CodeSize - 1
Put #fn, , data
data_buffer(0) = 0
bit_position = CHAR_BIT
'Process pixels data using LZW - GIF compression
For I = 1 To picHeight
Reinitialize
sPrefix = ""
intCode = buf(0, I)
On Error Resume Next
For J = 1 To picWidth - 1
sByte = MyFormat(buf(J, I))
sPrefix = sPrefix & sByte
intCode = colTable(sPrefix)
If Err <> 0 Then 'Prefix wasn't in collection - save it and output code
nCount = colTable.count
If nCount = MAX_CODE Then Reinitialize
colTable.Add nCount + FirstCode, sPrefix
OutputBits intCode, CodeSize
sPrefix = sByte
intCode = buf(J, I)
Err.Clear
End If
Next
OutputBits intCode, CodeSize
If I Mod 10 = 0 Then
RaiseEvent Progress(I * 100 / picHeight)
DoEvents
End If
Next
OutputCode (EndCode)
For I = 0 To data_buffer(0)
Put #fn, , data_buffer(I)
Next
data = 0
Put #fn, , data
Put #fn, , GifTerminator
Close fn
Erase buf
If hDc = 0 Then
SelectObject Src_hDc, OldObj
DeleteDC Src_hDc
End If
SelectObject hDC256, OldObj256
DeleteObject hDib256
DeleteDC hDC256
SaveGIF = True
IsBusy = False
End Function
搜索更多相关主题的帖子: Byte 格式 Type 文件 Private 
2007-02-05 17:40
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 
Private Sub OutputBits(Value As Integer, count As Integer)
Dim I As Integer, bit As Integer
Do While I < count
If bit_position >= CHAR_BIT Then
If data_buffer(0) = 255 Then
Put #fn, , data_buffer
data_buffer(0) = 1
Else
data_buffer(0) = data_buffer(0) + 1
End If
data_buffer(data_buffer(0)) = 0
bit_position = 0
End If
bit = Sgn(Power2(I) And Value)
If bit > 0 Then data_buffer(data_buffer(0)) = Power2(bit_position) Or data_buffer(data_buffer(0))
bit_position = bit_position + 1
I = I + 1
Loop
End Sub

Private Sub OutputCode(code As Integer)
code_count = code_count + 1
If code_count > LastCode Then
code_count = FirstCode
Call OutputBits(ClearCode, CodeSize)
ClearTable
End If
Call OutputBits(code, CodeSize)
End Sub

Private Sub ClearTable()
Set colTable = Nothing
Set colTable = New Collection
End Sub

Private Sub Reinitialize()
ClearTable
Call OutputBits(ClearCode, CodeSize)
End Sub

Private Function FileExists(ByVal strPathName As String) As Boolean
Dim af As Long
af = GetFileAttributes(strPathName)
FileExists = (af <> -1)
End Function

Private Function Power2(ByVal I As Integer) As Long
If aPower2(0) = 0 Then
aPower2(0) = &H1&
aPower2(1) = &H2&
aPower2(2) = &H4&
aPower2(3) = &H8&
aPower2(4) = &H10&
aPower2(5) = &H20&
aPower2(6) = &H40&
aPower2(7) = &H80&
aPower2(8) = &H100&
aPower2(9) = &H200&
aPower2(10) = &H400&
aPower2(11) = &H800&
aPower2(12) = &H1000&
aPower2(13) = &H2000&
aPower2(14) = &H4000&
aPower2(15) = &H8000&
aPower2(16) = &H10000
aPower2(17) = &H20000
aPower2(18) = &H40000
aPower2(19) = &H80000
aPower2(20) = &H100000
aPower2(21) = &H200000
aPower2(22) = &H400000
aPower2(23) = &H800000
aPower2(24) = &H1000000
aPower2(25) = &H2000000
aPower2(26) = &H4000000
aPower2(27) = &H8000000
aPower2(28) = &H10000000
aPower2(29) = &H20000000
aPower2(30) = &H40000000
aPower2(31) = &H80000000
End If
Power2 = aPower2(I)
End Function

Private Function MyFormat(ByVal s As String) As String
MyFormat = Right$("00" & s, 3)
End Function

Private Function CreateDib256(ByVal h_Dc As Long, bi As BITMAPINFO256) As Long
Dim lScanSize As Long
Dim lptr As Long, lIndex As Long
Dim r As Long, g As Long, b As Long
Dim rA As Long, gA As Long, bA As Long
With bi.bmiHeader
.biSize = Len(bi.bmiHeader)
.biWidth = picWidth
.biHeight = picHeight
.biPlanes = 1
.biBitCount = 8
.biCompression = BI_RGB
lScanSize = (picWidth + picWidth Mod 4)
.biSizeImage = lScanSize * picHeight
End With
' Halftone 256 colour palette
For b = 0 To &H100 Step &H40
If b = &H100 Then
bA = b - 1
Else
bA = b
End If
For g = 0 To &H100 Step &H40
If g = &H100 Then
gA = g - 1
Else
gA = g
End If
For r = 0 To &H100 Step &H40
If r = &H100 Then
rA = r - 1
Else
rA = r
End If
With bi.bmiColors(lIndex)
.rgbRed = rA: .rgbGreen = gA: .rgbBlue = bA
End With
lIndex = lIndex + 1
Next r
Next g
Next b
CreateDib256 = CreateDIBSection256(h_Dc, bi, DIB_RGB_COLORS, lptr, 0, 0)
End Function

[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2007-02-05 17:41
学习VB才2天
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1653
专家分:0
注 册:2006-5-4
收藏
得分:0 

利用VB捕捉并保存屏幕图象
大家知道在VB下利用API函数Bitblt可以将屏幕或者窗口上的图象拷贝到VB中的PictureBox对象中,但是如果简单的利用PictureBox的SavePicture函数来保存图象,会发现什么也保存不了。这篇文章就是介绍如何捕获并利用Windows下的OLE API函数保存图象。
  首先来看源程序,首先建立一个新的工程文件,然后在Form1中加入5个CommandButton对象和一个PictureBox对象,然后在Form1中加入以下代码:
Option Explicit
Option Base 0

Private Type PALETTEENTRY
  peRed As Byte
  peGreen As Byte
  peBlue As Byte
  peFlags As Byte
End Type

Private Type LOGPALETTE
  palVersion As Integer
  palNumEntries As Integer
  palPalEntry(255) As PALETTEENTRY
End Type

Private Type GUID
  Data1 As Long
  Data2 As Integer
  Data3 As Integer
  Data4(7) As Byte
End Type

Private Const RASTERCAPS As Long = 38
Private Const RC_PALETTE As Long = &H100
Private Const SIZEPALETTE As Long = 104

Private Type RECT
  Left As Long
  Top As Long
  Right As Long
  Bottom As Long
End Type

Private Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hDC As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "GDI32" (ByVal hDC As Long, _
    ByVal nWidth As Long, ByVal nHeight As Long) As Long
Private Declare Function GetDeviceCaps Lib "GDI32" (ByVal hDC As Long, ByVal _
    iCapabilitiy As Long) As Long
Private Declare Function GetSystemPaletteEntries Lib "GDI32" (ByVal hDC As Long, _
    ByVal wStartIndex As Long, ByVal wNumEntries As Long, lpPaletteEntries _
    As PALETTEENTRY) As Long
Private Declare Function CreatePalette Lib "GDI32" (lpLogPalette As LOGPALETTE) _
    As Long
Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Long, ByVal hObject _
    As Long) As Long
Private Declare Function BitBlt Lib "GDI32" (ByVal hDCDest As Long, ByVal XDest As _
    Long, ByVal YDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, _
    ByVal hDCSrc As Long, ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop _
    As Long) As Long
Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Long) As Long
Private Declare Function GetForegroundWindow Lib "USER32" () As Long
Private Declare Function SelectPalette Lib "GDI32" (ByVal hDC As Long, ByVal hPalette _
    As Long, ByVal bForceBackground As Long) As Long
Private Declare Function RealizePalette Lib "GDI32" (ByVal hDC As Long) As Long
Private Declare Function GetWindowDC Lib "USER32" (ByVal hWnd As Long) As Long
Private Declare Function GetDC Lib "USER32" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowRect Lib "USER32" (ByVal hWnd As Long, lpRect As _
    RECT) As Long
Private Declare Function ReleaseDC Lib "USER32" (ByVal hWnd As Long, ByVal hDC As _
    Long) As Long
Private Declare Function GetDesktopWindow Lib "USER32" () As Long

Private Type PicBmp
  Size As Long
  Type As Long
  hBmp As Long
  hPal As Long
  Reserved As Long
End Type

Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As _
    PicBmp, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long

注释:捕捉整个屏幕
Private Sub Command1_Click()
  Set Picture1.Picture = CaptureScreen()
End Sub

注释:在两秒钟后捕捉当前的活动窗口
Private Sub Command2_Click()
  MsgBox "当你关闭这个对话框两秒钟之后程序会捕捉处于活动状态的窗口."
  注释:等待两秒钟
  Dim EndTime As Date
  EndTime = DateAdd("s", 2, Now)
  Do Until Now > EndTime
    DoEvents
    Loop
  Set Picture1.Picture = CaptureActiveWindow()
  
  Me.SetFocus
End Sub

Private Sub Command3_Click()
  Set Picture1.Picture = Nothing
End Sub

Public Function CreateBitmapPicture(ByVal hBmp As Long, ByVal hPal As Long) As Picture
 Dim r As Long

  Dim Pic As PicBmp
  Dim IPic As IPicture
  Dim IID_IDispatch As GUID

  注释:填充IDispatch界面
  With IID_IDispatch
   .Data1 = &H20400
   .Data4(0) = &HC0
   .Data4(7) = &H46
  End With

  注释:填充Pic
  With Pic
   .Size = Len(Pic)     注释: Pic结构长度
   .Type = vbPicTypeBitmap  注释: 图象类型
   .hBmp = hBmp       注释: 位图句柄
   .hPal = hPal       注释: 调色板句柄
  End With

  注释:建立Picture图象
  r = OleCreatePictureIndirect(Pic, IID_IDispatch, 1, IPic)

  注释:返回Picture对象
  Set CreateBitmapPicture = IPic
End Function

Public Function CaptureWindow(ByVal hWndSrc As Long, ByVal Client As Boolean, ByVal _
  LeftSrc As Long, ByVal TopSrc As Long, ByVal WidthSrc As Long, ByVal HeightSrc _
  As Long) As Picture

  Dim hDCMemory As Long
  Dim hBmp As Long
  Dim hBmpPrev As Long
  Dim r As Long
  Dim hDCSrc As Long
  Dim hPal As Long
  Dim hPalPrev As Long
  Dim RasterCapsScrn As Long
  Dim HasPaletteScrn As Long
  Dim PaletteSizeScrn As Long
  Dim LogPal As LOGPALETTE

  If Client Then
    hDCSrc = GetDC(hWndSrc)
  Else
    hDCSrc = GetWindowDC(hWndSrc)
  End If

  hDCMemory = CreateCompatibleDC(hDCSrc)
  hBmp = CreateCompatibleBitmap(hDCSrc, WidthSrc, HeightSrc)
  hBmpPrev = SelectObject(hDCMemory, hBmp)

  注释:获得屏幕属性
  RasterCapsScrn = GetDeviceCaps(hDCSrc, RASTERCAPS)
  HasPaletteScrn = RasterCapsScrn And RC_PALETTE
  PaletteSizeScrn = GetDeviceCaps(hDCSrc, SIZEPALETTE)

  注释:如果屏幕对象有调色板则获得屏幕调色板
  If HasPaletteScrn And (PaletteSizeScrn = 256) Then
    注释:建立屏幕调色板的拷贝
    LogPal.palVersion = &H300
    LogPal.palNumEntries = 256
    r = GetSystemPaletteEntries(hDCSrc, 0, 256, LogPal.palPalEntry(0))
    hPal = CreatePalette(LogPal)
    注释:将新建立的调色板选如建立的内存绘图句柄中
    hPalPrev = SelectPalette(hDCMemory, hPal, 0)
    r = RealizePalette(hDCMemory)
  End If

  注释:拷贝图象
  r = BitBlt(hDCMemory, 0, 0, WidthSrc, HeightSrc, hDCSrc, LeftSrc, TopSrc, vbSrcCopy)

  hBmp = SelectObject(hDCMemory, hBmpPrev)

  If HasPaletteScrn And (PaletteSizeScrn = 256) Then
    hPal = SelectPalette(hDCMemory, hPalPrev, 0)
  End If

  注释:释放资源
  r = DeleteDC(hDCMemory)
  r = ReleaseDC(hWndSrc, hDCSrc)

  Set CaptureWindow = CreateBitmapPicture(hBmp, hPal)
End Function
注释:capturescreen函数捕捉整个屏幕图象
Public Function CaptureScreen() As Picture
  Dim hWndScreen As Long

  注释:获得桌面的窗口句柄
  hWndScreen = GetDesktopWindow()
  Set CaptureScreen = CaptureWindow(hWndScreen, False, 0, 0, Screen.Width _
    \ Screen.TwipsPerPixelX, Screen.Height \ Screen.TwipsPerPixelY)
End Function

Public Function CaptureActiveWindow() As Picture
  Dim hWndActive As Long
  Dim r As Long
  Dim RectActive As RECT
  
  hWndActive = GetForegroundWindow()
  r = GetWindowRect(hWndActive, RectActive)
  Set CaptureActiveWindow = CaptureWindow(hWndActive, False, 0, 0, _
    RectActive.Right - RectActive.Left, RectActive.Bottom - RectActive.Top)
End Function

Public Sub PrintPictureToFitPage(Prn As Printer, Pic As Picture)
  Const vbHiMetric As Integer = 8
  Dim PicRatio As Double
  Dim PrnWidth As Double
  Dim PrnHeight As Double
  Dim PrnRatio As Double
  Dim PrnPicWidth As Double
  Dim PrnPicHeight As Double
  
  If Pic.Height >= Pic.Width Then
    Prn.Orientation = vbPRORPortrait
  Else
    Prn.Orientation = vbPRORLandscape
  End If
  
  PicRatio = Pic.Width / Pic.Height
  
  PrnWidth = Prn.ScaleX(Prn.ScaleWidth, Prn.ScaleMode, vbHiMetric)
  PrnHeight = Prn.ScaleY(Prn.ScaleHeight, Prn.ScaleMode, vbHiMetric)
  PrnRatio = PrnWidth / PrnHeight
  
  If PicRatio >= PrnRatio Then
    PrnPicWidth = Prn.ScaleX(PrnWidth, vbHiMetric, Prn.ScaleMode)
    PrnPicHeight = Prn.ScaleY(PrnWidth / PicRatio, vbHiMetric, Prn.ScaleMode)
  Else
    PrnPicHeight = Prn.ScaleY(PrnHeight, vbHiMetric, Prn.ScaleMode)
    PrnPicWidth = Prn.ScaleX(PrnHeight * PicRatio, vbHiMetric, Prn.ScaleMode)
  End If
  
  Prn.PaintPicture Pic, 0, 0, PrnPicWidth, PrnPicHeight
End Sub

Private Sub Command4_Click()
  CommonDialog1.DefaultExt = ".BMP"
  CommonDialog1.Filter = "Bitmap Image (*.bmp)|*.bmp"
  CommonDialog1.ShowSave
  If CommonDialog1.FileName <> "" Then
    SavePicture Picture1.Picture, CommonDialog1.FileName
  End If
End Sub

Private Sub Command5_Click()
  PrintPictureToFitPage Printer, Picture1.Picture
  Printer.EndDoc
End Sub

Private Sub Form_Load()
  Command1.Caption = "捕捉整个屏幕"
  Command2.Caption = "两秒钟后捕捉活动窗口"
  Command3.Caption = "清除图象"
  Command4.Caption = "保存图象"
  Command5.Caption = "打印图象"
End Sub

  运行程序,点击command1或者Command2就可以捕捉成个屏幕或者窗口到Picture1中,然后点击Command4或者Command5就可以保存或打印图象。
  上面的程序中最重要的是CaptureWindow函数以及CreateBitmapPicture函数,CaptureWindow函数建立与要捕捉的窗口的绘图设备(Device Context)句柄相兼容的绘图设备(Device Context)句柄,然后建立相应的调色板,最后将绘图设备(Device Context)中的图象拷贝到一个hBitmap对象句柄中。CreateBitmapPicture函数则根据传递过来的hBitmap对象句柄和调色板句柄建立一个Picture对象。在将这个对象赋予PictureBox的Picture属性,然后就可以使用SavePicture函数来保存图象了。


[GLOW=255,DeepPink,3]我的免费网盘[/GLOW]
2007-02-05 17:44
快速回复:[转载]VB实现图片文件格式的转换````
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015942 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved