Re: PurePDF Version 2.0
Posted: Sun Oct 06, 2013 8:09 am
Please upload those images somewhere so that i can test whats going wrong.
http://www.purebasic.com
https://www.purebasic.fr/english/
I think I don't need to upload image, I have use the pdf_GetErrorMessage() to see what is going on.ABBKlaus wrote:Please upload those images somewhere so that i can test whats going wrong.
And my first png logo use alpha channel. I have try to save my logo as jpeg image using "The Gimp" V2.8 and apparently if I use the "Progressive" option :Debugger wrote:Alpha channel PNG not supported.
Apparently the Progressive image load for the web generate a bug. I hope this will help you to figure out this bug.Debugger wrote:Not a JPEG file.
Code: Select all
Procedure ipdf_ParseJPG(*aData.MEM_DataStructure)
Protected vStart,vLength,vFound,vResult,vByte.b
;Block Length
vLength = ((PeekB(*aData\pData + 4) & $FF)*$100) + (PeekB(*aData\pData + 5) & $FF)
vStart = 4 + vLength
vFound = #False
While (vFound <> #True) And (vStart + 9 < *aData\lCurSize)
vByte=PeekB(*aData\pData + vStart) & $FF
If vByte = -1
vByte = PeekB(*aData\pData + vStart + 1) & $FF
If (vByte = -64) Or (vByte = -62)
vFound = #True
Images()\Bpc = PeekB(*aData\pData + vStart + 4)
Images()\Height = ((PeekB(*aData\pData + vStart + 5) & $FF)*$100) + (PeekB(*aData\pData + vStart + 6) & $FF)
Images()\Width = ((PeekB(*aData\pData + vStart + 7) & $FF)*$100) + (PeekB(*aData\pData + vStart + 8) & $FF)
; Gray = 1/Color = 3
Select PeekB(*aData\pData + vStart + 9) & $FF
Case 1
Images()\ColSpace = "DeviceGray"
Case 3
Images()\ColSpace = "DeviceRGB"
Default:
Images()\ColSpace = "DeviceCMYK"
EndSelect
Images()\DataPic\pData = *aData\pData
Images()\DataPic\lCurSize = *aData\lCurSize
vResult = #True
Else
;Block Length
vLength = ((PeekB(*aData\pData + vStart + 2) & $FF)*$100) + (PeekB(*aData\pData + vStart + 3) & $FF)
vStart = vStart + vLength + 2
EndIf
Else
pdfError = #PDF_ERROR_JPEG_FILE_IS_NOT_SUPPORTED
vResult = #False
Break
EndIf
Wend
ProcedureReturn vResult
EndProcedure
Yup, that's the way to go.ABBKlaus wrote:...
[/Edit]Found it : *Buffer = EncodeImage(#Image [, ImagePlugin [, Flags [, Depth]]])[Edit]
Thank you for this additional example.Loopingstar wrote:I give an example of "encodeImage" in another of my posts: http://www.purebasic.fr/english/viewtop ... 13&t=56927
- ipdf_Handle_MS_Encoding() changed variable n.w to n.u
- ipdf_Handle_MS_Encoding() fixed broken glyph code detection
Code: Select all
#PurePDF_Include=1
;Put you path pointing to "PurePDF.pb" and "PurePDF.res" here:
IncludePath "....\PurePDF\Examples\PurePDF\"
;
XIncludeFile "PurePDF_res.pb"
XIncludeFile "PurePDF.pb"
Define Logo.s, myPath.s, Error.s
Define ImgW,i, ImgH.i
Define Quality.i
Define *myImgBuffer
UsePNGImageDecoder()
UseJPEGImageEncoder()
Logo.s=#PB_Compiler_Home+"Examples\3D\Data\PureBasic3DLogo.png"
;Put your path for PDF and JPG files here
myPath.s="...."
;
If LoadImage(1, Logo)
ImgW=ImageWidth(1)
ImgH=ImageHeight(1)
For Quality= 0 To 10
Debug "Loop start ---"
*myImgBuffer=EncodeImage(1, #PB_ImagePlugin_JPEG, Quality)
If *myImgBuffer
Debug "Quality: "+Str(Quality)
pdf_Create("P", "pt", Str(ImgW)+","+Str(ImgH))
pdf_setmargins(0,0,0)
pdf_AddPage()
pdf_ImageMem("", *myImgBuffer, MemorySize(*myImgBuffer), 0, 0)
Debug pdf_geterrormessage()
pdf_Save(myPath+"\PDFTestQ"+Str(Quality)+".pdf")
Debug pdf_geterrormessage()
; save JPG for reference purpose
SaveImage(1 , myPath+"\JPGTestQ"+Str(Quality)+".jpg", #PB_ImagePlugin_JPEG, Quality)
;
FreeMemory(*myImgBuffer)
EndIf
Debug "Loop end ----"
Next Quality
EndIf