Hi,
I want to know how to create sprite images for PNG files using ISource?
Thanks in advance.
Hi,
I want to know how to create sprite images for PNG files using ISource?
Thanks in advance.
what is a 'sprite image' ?
-c
Chris Losinger
Smaller Animals Software, Inc
Hi,
I want to stich the images into one image(merge images togather to certain width then rest of the iamges next row likewise..).
Thanks in advance.
Hi,
Sorry ignore the previous re.
I want to stich the images into one image(merge images togather to certain width side by side, then rest of the images next row likewise..).
Thanks in advance.
allocate a blank image large enough to hold all your images, then use IS3OverlayImage to overlay each sub-image onto the output image.
Chris Losinger
Smaller Animals Software, Inc
Hi Chris,
As you said i tried to use Is3OverlayImage. But it is not working for me. Can you tell me what is wrong in this code?
GetImageDimensions function is to identify the total width and height for the new image.
Public Function GetImageDimensions(ByVal infile As String)
Dim hFileSource As Long
hFileSource = IS3OpenFileSource(infile)
bret = IS3GetPNGDims(hFileSource, BITMAP_X_ORG, BITMAP_Y_ORG, lbitdepth, lColorType, lInterfaceType, pDPIStruct)
IS3CloseSource (hFileSource)
GlobalFree (hImgSource)
If lDestHeight < BITMAP_Y_ORG Then
lDestHeight = BITMAP_Y_ORG
End If
lTotalHeight = lTotalHeight + BITMAP_Y_ORG
lTotalWidth = lTotalWidth + BITMAP_X_ORG
lPrevImg = lPrevImg + 1
ReDim Preserve InputFiles(lPrevImg) As String
InputFiles(lPrevImg - 1) = infile
End Function
After getting the size, am calling this function to create new image:
Public Function CreateSprite(ByVal outfile As String) As Boolean
If outfile = "" Then
outfile = "E:\Develoment\Offline(5.0)\MergeImgs\10.png"
'Remove output file if it exists
On Error Resume Next
Kill (outfile)
End If
Dim hDest As Long, pData As Long
Dim iXpos As Long, iYpos As Long
Dim bret As Boolean
'hDest = IS3OpenFileDest(outfile, 0)
'
'If hDest Then
pData = GlobalAlloc(0, lTotalWidth * lDestHeight * 3) ' row
For i = 0 To 5
Dim pSrc As Long
pSrc = IS3OpenFileSource(InputFiles(i))
bret = IS3GetPNGDims(pSrc, BITMAP_X_ORG, BITMAP_Y_ORG, lbitdepth, lColorType, lInterfaceType, pDPIStruct)
bret = IS3OverlayImage(pData, lTotalWidth, lDestHeight, 3, BITMAP_Y_ORG * 3, pSrc, BITMAP_X_ORG, BITMAP_Y_ORG, BITMAP_X_ORG * 3, iXpos, iYpos, 0, 0)
iXpos = iXpos + BITMAP_X_ORG
' iYpos = iYpos + BITMAP_Y_ORG
IS3CloseSource (pSrc)
Next
'GlobalFree pData
'End If
hDest = IS3OpenFileDest(outfile, 1)
If hDest Then
IS3WritePNG hDest, pData, lTotalWidth, lDestHeight, lTotalWidth * 3, 8, 0, ByVal 0, 2, 0, ByVal 0, 0
GlobalFree pData
End If
IS3CloseDest hDest
CreateSprite = True
End Function
The output image is showing full black.
Thanks.
In my previous reply the code for Is3OverlayImage is
bret = IS3OverlayImage(pData, lTotalWidth, lDestHeight, 3, BITMAP_X_ORG * 3, pSrc, BITMAP_X_ORG, BITMAP_Y_ORG, BITMAP_X_ORG * 3, iXpos, iYpos, 0, 0)
not
bret = IS3OverlayImage(pData, lTotalWidth, lDestHeight, 3, BITMAP_Y_ORG * 3, pSrc, BITMAP_X_ORG, BITMAP_Y_ORG, BITMAP_X_ORG * 3, iXpos, iYpos, 0, 0)
I tried the other way also:
bret = IS3OverlayImage(pData, lTotalWidth, lDestHeight, 3, lTotalWidth * 3, pSrc, BITMAP_X_ORG, BITMAP_Y_ORG, BITMAP_X_ORG * 3, iXpos, iYpos, 0, 0)
Then also it is not working.
Thanks and Regards.
>In my previous reply the code for Is3OverlayImage is
>
>bret = IS3OverlayImage(pData, lTotalWidth, lDestHeight, 3,
>BITMAP_X_ORG * 3, pSrc, BITMAP_X_ORG, BITMAP_Y_ORG,
>BITMAP_X_ORG * 3, iXpos, iYpos, 0, 0)
>
the number of bytes per row in the bottom image (rowStride) is probably lTotalWidth * 3, not BITMAP_X_ORG * 3
Chris Losinger
Smaller Animals Software, Inc
Tried that also Chris. It is not working.
> hDest = IS3OpenFileDest(outfile, 1)
try
hDest = IS3OpenFileDest(outfile, 0)
Chris Losinger
Smaller Animals Software, Inc
Tried that too Chris.
Am feeling the problem is in this logic :
1)using globalalloc allocating size for the desination in a long variable.
2)after that calling overlayimage.
3)then finally open the destination and writing the overlay output to that file.
Dim hDest As Long, pData As Long
Dim iXpos As Long, iYpos As Long
Dim bret As Boolean
pData = GlobalAlloc(0, lTotalWidth * lDestHeight * 3) ' row
For i = 0 To 5
Dim pSrc As Long
pSrc = IS3OpenFileSource(InputFiles(i))
bret = IS3GetPNGDims(pSrc, BITMAP_X_ORG, BITMAP_Y_ORG, lbitdepth, lColorType, lInterfaceType, pDPIStruct)
bret = IS3OverlayImage(pData, lTotalWidth, lDestHeight, 3, lTotalWidth * 3, pSrc, BITMAP_X_ORG, BITMAP_Y_ORG, BITMAP_X_ORG * 3, iXpos, iYpos, 0, 0)
iXpos = iXpos + (BITMAP_X_ORG * 3)
IS3CloseSource (pSrc)
Next
hDest = IS3OpenFileDest(outfile, 0)
If hDest Then
IS3WritePNG hDest, pData, lTotalWidth, lDestHeight, lTotalWidth * 3, 8, 0, ByVal 0, 2, 0, ByVal 0, 0
GlobalFree pData
End If
IS3CloseDest hDest
> pSrc = IS3OpenFileSource(InputFiles(i))
>
...
> bret = IS3OverlayImage(pData, lTotalWidth,
>lDestHeight, 3, lTotalWidth * 3, pSrc, BITMAP_X_ORG,
>BITMAP_Y_ORG, BITMAP_X_ORG * 3, iXpos, iYpos, 0, 0)
pSrc is not an image. pSrc is an input manager object. you need to read the image from the file that pSrc is pointing to (use either IS3ReadPNG or IS3ReadImageToRGB)
Chris Losinger
Smaller Animals Software, Inc
Dim pSrc As Long,hImgSource as long
pSrc = IS3OpenFileSource(InputFiles(i))
' bret = IS3GetPNGDims(pSrc, BITMAP_X_ORG, BITMAP_Y_ORG, lbitdepth, lColorType, lInterfaceType, pDPIStruct)
hImgSource = IS3ReadPNG(pSrc, BITMAP_X_ORG, BITMAP_Y_ORG, 24, ByVal 0, 0)
bret = IS3OverlayImage(pData, lTotalWidth, lDestHeight, 3, lTotalWidth * 3, hImgSource, BITMAP_X_ORG, BITMAP_Y_ORG, BITMAP_X_ORG * 3, iXpos, iYpos, 0, 0)
iXpos = iXpos + (BITMAP_X_ORG * 3)
' iYpos = iYpos + BITMAP_Y_ORG
IS3CloseSource (pSrc)
GlobalFree (hImgSource)
I tried as you said with IS3ReadPNG. Still it is not.
>Dim pSrc As Long,hImgSource as long
>
> pSrc = IS3OpenFileSource(InputFiles(i))
>
> hImgSource = IS3ReadPNG(pSrc, BITMAP_X_ORG,
>BITMAP_Y_ORG, 24, ByVal 0, 0)
>
what are the values of hImgSource, BITMAP_X_ORG and BITMAP_Y_ORG ?
and, if they look strange, put a call to IS3GetLastError right here.
> bret = IS3OverlayImage(pData, lTotalWidth,
>lDestHeight, 3, lTotalWidth * 3, hImgSource, BITMAP_X_ORG,
>BITMAP_Y_ORG, BITMAP_X_ORG * 3, iXpos, iYpos, 0, 0)
>
what is the value of bret ?
Chris Losinger
Smaller Animals Software, Inc
IS3GetLastError returns 0.
The value for bret is True after the excution of IS3Overlayimage method.
Hi Chris,
Dim pData As Long
Dim bret As Boolean
Dim hImgSource As Long
pData = GlobalAlloc(0, lTotalWidth * lDestHeight * 3) ' row
For i = 0 To 1
Dim pSrc As Long
pSrc = IS3OpenFileSource(InputFiles(i))
hImgSource = IS3ReadPNG(pSrc, BITMAP_X_ORG, BITMAP_Y_ORG, 24, ByVal 0, 0)
bret = IS3OverlayImage(pData, lTotalWidth, lDestHeight, 3, lTotalWidth * 3, hImgSource, BITMAP_X_ORG, BITMAP_Y_ORG, BITMAP_X_ORG * 3, iXpos, iYpos, 0, 0)
In the above the pData which am passing to IS3OverlayImage is not an image object. Just after allocating size for it am using in the method. Is it ok?
> bret = IS3OverlayImage(pData, lTotalWidth,
>lDestHeight, 3, lTotalWidth * 3, hImgSource, BITMAP_X_ORG,
>BITMAP_Y_ORG, BITMAP_X_ORG * 3, iXpos, iYpos, 0, 0)
>
>In the above the pData which am passing to IS3OverlayImage is
>not an image object. Just after allocating size for it am
>using in the method. Is it ok?
yes. ImgSource doesn't use an "image object" concept. an image is just a buffer of BYTEs.
what are the values of the variables you're passing to IS3OverlayImage ?
Chris Losinger
Smaller Animals Software, Inc
I notice you are passing 0, 0 as the last parameters of IS3OverlayImage. I could be wrong, but doesn't that make the top image transparent?
Hi Chris,
Sorry for delay.
if i change the parameter to 1,0 then it is working fine.
Thanks.