I wrote a function which may be helpful for you to convert the icon to "purebasic image format"
Code: Select all
Procedure CopyImageWithDepth(Source.i,Destination.i,Depth=32)
If ImageDepth(Source,#PB_Image_OriginalDepth)<>Depth Or ImageFormat(Source)=#PB_ImagePlugin_ICON Or ImageFrameCount(Source)<>1 CreateImage(Destination,ImageWidth(Source)+Border<<1,ImageHeight(Source)+Border<<1,Depth,#PB_Image_Transparent);
StartDrawing(ImageOutput(Destination))
DrawingMode(#PB_2DDrawing_AllChannels); Alpha-Channel=255 bei 24-Bit-Bildern (im Default-Modus=0)
DrawImage(ImageID(Source),Border,Border)
StopDrawing()
Else
CopyImage(Source,Destination)
EndIf
EndProcedure
Something else I have done for creating dynamic icons (useful for systray animation, etc.), maybe helpful somewhen...
Code: Select all
; File-Header 6 Bytes
Data.w 0; 0 (File Identifier)
Data.w 1; 1=Ico, 2=Cur
Data.w 1; [n]=Number of Images
; List of Icons 16 Bytes * [n]
Data.a 20; Width (0=256)
Data.a 20; Height (0=256)
Data.a 0; [c]=Color Count (0=256 Colors)
Data.a 0; 0 (Reserved)
Data.w 1; Ico: Color Planes (0 or 1), Cur: X-Hotspot
Data.w 32; Ico: Bits per Pixel, Cur: Y-Hotspot
Data.l 1720; Bitmap Data Size (in bytes, z.B. InfoHeader+20*20*4+XorBitmap)
Data.l 22; File Offset (InfoHeader)
; Icon Data I InfoHeader: 40 Bytes
Data.l 40; Size of InfoHeader
Data.l 20; Icon Width
Data.l 40; Icon Height (=XorBitmap + And-Bitmap)
Data.w 1; Number of Planes (1)
Data.w 32; Ico: Bits per Pixel
Data.l 0; Compression-Type (0=uncompressed)
Data.l 0; Size of Image in Bytes (0=uncompressed)
Data.l 0; X-PixelsPerM (0=unused)
Data.l 0; Y-PixelsPerM (0=unused)
Data.l 0; Colors used (0=unused)
Data.l 0; Colors important (0=unused)
; Icon Data II Color Map for Xor-Bitmap: 4 Bytes * [c]
Data.a 255; red
Data.a 255; green
Data.a 255; blue
Data.a 0; reserved (0)
; Icon Data III Bitmaps
Data.a 0;... And-Bitmap (z.B. 20x20x4 Bytes)
Data.l 0;... Xor-Bitmap (z.B. 20x4* Bytes) *) 8 Pixel pro Byte > 20/8=2.5 > 4, weil pro Zeile auf 32 Bit aufgerundet wird