Relatively speaking, it's not hard, we don't need a decoder to get every byte of jpg, or anything like that, instead, we'll use a picture frame to open a picture and then upload it to the surface, but first we need to declare the API function:
Public 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
Public Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hdc as long) as long
Public Declare Function DeleteDC Lib "GDI32" (ByVal hdc as long) as long
Public Declare Function SelectObject Lib "GDI32" (ByVal hdc as Long, ByVal hobject as long) as long
Public Declare Function StretchBlt Lib "GDI32" (ByVal hdc 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 nsrcwidth as Long, ByVal Nsrch Eight as long, ByVal Dwrop as Long
Now we're ready to load the picture.
Dim Pict1 as StdPicture
Set Pict1 = LoadPicture ("mypict.jpg")
Create the Surface:
Dim Tdesc as DDSurfaceDesc2
Tdesc.lflags = Ddsd_caps or Ddsd_height or ddsd_width
TDesc.ddsCaps.lCaps = Ddscaps_offscreenplain
Tdesc.lheight = CLng (pict1.height * 0.001) * 567/screen.twipsperpixely)
Tdesc.lwidth = CLng (tpict.width * 0.001) * 567/screen.twipsperpixelx)
Set Surf = Ddraw.createsurface (TDESC)
Dim SURFDC as Long, pictdc as Long
SURFDC = Surf.getdc
PICTDC = CreateCompatibleDC (0)
SelectObject Pict1.handle, PICTDC
We will use DCs and BitBlt or StretchBlt to copy the Pic1 to the surface
Copy only the same size:
BitBlt SURFDC, 0, 0, tdesc.lwidth, tdesc.lheight, PICTDC, 0, 0, vbsrccopy
Now copy and change the picture size
StretchBlt SURFDC, 0, 0, stretchwidth, stretchheight, PICTDC, 0, 0, tdesc.lwidth, Tdesc.lwidth, vbsrccopy
Free DC:
Surf.releasedc SURFDC
Delectedc PICTDC
Set Pict1 = Nothing