
j'essaie de traduire un code vers #PB,le code il sert à convertir n'importe type d'image en icon mais sans succès et je ne sais pas ce qui cloche

merci de m'aider

original code
https://www.codeproject.com/Questions/1 ... -the-color
mon code
Code : Tout sélectionner
EnableExplicit
Structure ICONDIRENTRY
bWidth.b; // Width, in pixels, of the image
bHeight.b; // Height, in pixels, of the image
bColorCount.b; // Number of colors in image (0 if >=8bpp)
bReserved.b ; // Reserved ( must be 0)
wPlanes.w ; // Color Planes
wBitCount.w ; // Bits per pixel
dwBytesInRes.l; // How many bytes in this resource?
dwImageOffset.l; // Where in the file is this image?
EndStructure
Structure ICONDIR
idReserved.w; // Reserved (must be 0)
idType.w ; // Resource Type (1 for icons)
idCount.w ; // How many images?
EndStructure
Structure GdiplusStartupInput
GdiplusVersion.l
DebugEventCallback.i
SuppressBackgroundThread.l
SuppressExternalCodecs.l
EndStructure
Import "gdiplus.lib"
EncoderQuality.GUID
GdiplusStartup.l(*token, *input.GdiplusStartupInput,*output)
GdipDisposeImage.l(GpImage)
GdipCreateBitmapFromScan0.l(iWidth.l ,iHeight.l ,iStride.l ,iPixelFormat.l ,*pScan0 ,*iHbitmp)
GdipDeleteGraphics.l(hGraphics.i)
GdipCreateBitmapFromFile.l(Imagepath.s, *GpBitmap)
GdipGetImageWidth.l(GpImage, *width)
GdipGetImageHeight.l(GpImage, *height)
GdipCreateHICONFromBitmap.l(GpImage, *Hicon)
GdipGetImageThumbnail.l(GpImage,iWidth.l, iHeight.l,*GpBitmap,*hCallback,*hCallbackData)
EndImport
Procedure Gdiplus_Startup()
Protected iToken.l=0,input.GdiplusStartupInput\GdiplusVersion = 1:GdiplusStartup(@iToken, @input, 0):ProcedureReturn iToken
EndProcedure
Procedure Gdiplus_CreateImageFromFile(sFile.s)
Protected Gdimg:GdipCreateBitmapFromFile(sFile,@Gdimg):ProcedureReturn Gdimg
EndProcedure
Procedure Gdiplus_CreateHiconFromImage(Gdimg)
Protected Hicon:GdipCreateHICONFromBitmap(Gdimg,@Hicon):ProcedureReturn Hicon
EndProcedure
Procedure Gdiplus_DisposeImage(Gdimg)
ProcedureReturn GdipDisposeImage(Gdimg)
EndProcedure
Procedure Gdiplus_GetImageThumbnail(GpImage,iWidth.l, iHeight.l)
Protected Gdimg:GdipGetImageThumbnail(GpImage,iWidth,iHeight,@Gdimg,0,0):ProcedureReturn Gdimg
EndProcedure
DisableExplicit
Gds= Gdiplus_Startup()
img=Gdiplus_CreateImageFromFile("Test.bmp")
imgt=Gdiplus_GetImageThumbnail(img,32, 32)
hicon=Gdiplus_CreateHiconFromImage(img)
ici.ICONINFO
GetIconInfo_(hicon,@ici)
ibmt.DIBSECTION:ibct.DIBSECTION
ibm=CopyImage_(ici\hbmMask,#IMAGE_BITMAP,0,0,#LR_COPYDELETEORG|#LR_CREATEDIBSECTION)
ibc=CopyImage_(ici\hbmColor,#IMAGE_BITMAP,0,0,#LR_COPYDELETEORG|#LR_CREATEDIBSECTION)
GetObject_(ibm,SizeOf(DIBSECTION),@ibmt)
GetObject_(ibc,SizeOf(DIBSECTION),@ibct)
icd.ICONDIR
icd\idType=1
icd\idCount=1
icde.ICONDIRENTRY
icde\wPlanes=ibct\dsBm\bmPlanes
icde\wBitCount=ibct\dsBm\bmBitsPixel
icde\dwBytesInRes=SizeOf(BITMAPINFOHEADER)+ibct\dsBmih\biSizeImage
icde\dwImageOffset=SizeOf(ICONINFO)+SizeOf(ICONDIRENTRY)
icde\bWidth=ibct\dsBm\bmWidth
icde\bHeight=ibct\dsBm\bmHeight
tb.BITMAPINFOHEADER
tb\biSize=SizeOf(BITMAPINFOHEADER)
tb\biPlanes=1
tb\biWidth=ibct\dsBm\bmWidth
tb\biHeight=ibct\dsBm\bmHeight+ibmt\dsBm\bmHeight
tb\biBitCount=ibct\dsBm\bmBitsPixel
tb\biSizeImage=ibct\dsBmih\biSizeImage
CreateFile(0,"Test.ico")
WriteData(0,icd,SizeOf(ICONDIR))
WriteData(0,icde,SizeOf(ICONDIRENTRY))
WriteData(0,tb,SizeOf(BITMAPINFOHEADER))
WriteData(0, ibct\dsBm\bmBits,ibct\dsBmih\biSizeImage)
WriteData(0, ibmt\dsBm\bmBits,ibmt\dsBmih\biSizeImage)
CloseFile(0)
DeleteObject_(ibm)
DeleteObject_(ibc)
DestroyIcon_(hicon)
Gdiplus_DisposeImage(img)
Gdiplus_DisposeImage(imgt)