首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

GDI+ 图像数据读写有关问题

2012-03-19 
GDI+ 图像数据读写问题先上代码:Dim graphics As LongDim p As LongDim p1 As POINTF, p2 As POINTFDim fl

GDI+ 图像数据读写问题
先上代码:
Dim graphics As Long
Dim p As Long
Dim p1 As POINTF, p2 As POINTF
Dim flag As Integer
Dim bitmap As Long
Dim aaa As GdiplusStartupInput

Private Sub Form_load()
  Dim flag As Integer
  aaa.DebugEventCallback = 0
  aaa.GdiplusVersion = 1
  aaa.SuppressBackgroundThread = 0
  aaa.SuppressExternalCodecs = 0
  'initgdiplus
  Dim BmW As Long
  Dim BmH As Long
  Dim color() As Long
  Dim i As Long, j As Long
   
  p1.x = 30
  p1.y = 30
  p2.x = 100
  p2.y = 100
   
  GdiplusStartup p, aaa, Null
  GdipCreateFromHDC Picture1.hdc, graphics
  GdipCreateBitmapFromGraphics Picture1.ScaleWidth, Picture1.ScaleHeight, graphics, bitmap
  GdipGetImageWidth bitmap, BmW
  GdipGetImageHeight bitmap, BmH
   
   
  ReDim color(BmW - 1, BmH - 1)
  For i = 0 To BmW - 1
  For j = 0 To BmH - 1
  flag = GdipBitmapGetPixel(bitmap, i, j, color(i, j))
  color(i, j) = color(i, j) And &H80FFFFFF
  flag = GdipBitmapSetPixel(bitmap, i, j, color(i,j))
  Next
  Next  
  Picture1.Refresh
End Sub

Private Sub Form_Unload(Cancel As Integer)
  GdipDeleteGraphics bitmap
  GdipDeleteGraphics graphics '释放graphics占用的内存
  GdiplusShutdown p
End Sub


在用GdipBitmapGetPixel读数据的时候返回是成功的,可是color(i,j)里面全是0,
用GdipBitmapSetPixel写数据的时候也写不进去!
请指点一下!

[解决办法]
flag = GdipBitmapSetPixel(bitmap, i, j, color(i, j))

这句里有中文全角符号
[解决办法]
能不能把代码贴全了?GdiplusStartupInput的定义我就没有,找不到。
[解决办法]
GDI好像API浏览器里加载的不是Win32API.txt

探讨
能不能把代码贴全了?GdiplusStartupInput的定义我就没有,找不到。

[解决办法]
我百度了也没有找到这个定义。

热点排行