Difference in CatchImage behavior on Windows and MacOS

Just starting out? Need help? Post your questions and find answers here.
mestnyi
Addict
Addict
Posts: 995
Joined: Mon Nov 25, 2013 6:41 am

Difference in CatchImage behavior on Windows and MacOS

Post by mestnyi »

why might this not work on windows?
mac os works.

Code: Select all

; UseJPEGImageDecoder() 
; UseJPEG2000ImageDecoder() 
; UsePNGImageDecoder() 
; UseTIFFImageDecoder() 
; UseTGAImageDecoder() 
; UseGIFImageDecoder() 


img = CatchImage( #PB_Any, ?img_info, ?end_img_info - ?img_info )
Debug IsImage(img)

End

;      DataSection
;        img_info: 
;        IncludeBinary #PB_Compiler_Home + "examples/sources/Data/Background.bmp"
;        end_img_info:
;      EndDataSection

DataSection
  img_info:
  ; size : 1404 bytes
  Data.q $0A1A0A0D474E5089, $524448490D000000, $2800000028000000, $B8FE8C0000000608, $474B62060000006D
  Data.q $A0FF00FF00FF0044, $493105000093A7BD, $5F98CD8558544144, $3B3BBFC71C47144C, $54C0F03D7F7BB707
  Data.q $14DA0D5AD0348C10, $7C1A6360A90B6D6D, $6D03CAADF49898D3, $D1A87D7AD262545F, $B69B5F469AA9349A
  Data.q $680D82AB6C37D269, $A6220B47FA51A890, $DECFEE38E105102A, $053FB87D333B772E, $CCDD3CF850EE114A
  Data.q $0766FDFE767ECCDC, $F476DC569948E258, $5BCA94AD89227ADA, $3C10B9638C15E085, $7A59504C89240017
  Data.q $8055B371E2774802, $2E678FEAA9A17AFC, $06961711C3AC7F58, $EF905DD4CA91A322, $A159B0EAD38F5EA2
  Data.q $4D30000CA9417358, $1A3033484098DD06, $2C671601A343EB08, $EDD3F547A138B820, $DAFB560A82C89ABE
  Data.q $2E1D2C863E5562A8, $3CD50AAB359173CC, $8D8C00262FCE6397, $83FB0DA43FD7D187, $DDAAFF5D74F85C02
  Data.q $B3A477582D666357, $45754E5D9B42C73C, $16732AAEDD894565, $41FBABA3A6B0899B, $3FAB16311F45A424
  Data.q $8FDB82C66F4B707F, $1595D6EF9001DD5F, $69B32B24BD2B2529, $EA0DEEB7E6181FDC, $9D9F369A5BB6326
  Data.q $A94FBDAEC7BBE0B7, $A732EAE5951BF5F4, $5C114204D2DD216D, $6B9C344C651BD9B9, $5F8FDB82CE66FAAA
  Data.q $5F57EDFEF90841DD, $8469F486ECB61D52, $C2634777AE971D35, $2A9E9FF5E072D5DC, $8DE85A9CB3A47758
  Data.q $4DCF559EDB963737, $0D1DD74741182C67, $C9DDD550E5F86C71, $E68DAFB555E65365, $79E522B2BAF36858
  Data.q $B2DAC765C78001C9, $8DAFB573522C2B62, $8F9455C8929B2E4E, $77B1059330B54E5C, $D579F26E672AD4E3
  Data.q $AC8D0E0F2BD2BD5F, $9F9532F8021F1304, $C910838758FEB56E, $816E0DF732515957, $DAAF81036D5F2CA9
  Data.q $C2E305A5E54F66D7, $73EED922E79850D2, $88B9E6F02BB0E0D9, $2241697952FB2AA2, $B51C5D50B8ACB1A3
  Data.q $69322368555B297F, $A654FC089009A54C, $1E34DD1B45EE65EE, $5F9F7579224403B7, $416D440905240B59
  Data.q $244059B47C668BBE, $56F2A644DDF22B00, $1EBC77E473482920, $E3DCB126CD5175A7, $E720A4816B952854
  Data.q $AA1C1F8C97DBB0A8, $3CE0A0A481CA0015, $2829A74C5DCDCD5F, $0F5481799C981CD6, $9356B8BCB2A56E0A
  Data.q $0B4C0AC3821950B0, $6188962AC4914B75, $8326E2692ED8B632, $32112C58C9006044, $ECE858E5B0989D1A
  Data.q $743677B1BE616735, $07BA4027E44A0623, $6C80F60B188E13D1, $829201DC00066B09, $8C96858E8E2EC9A6
  Data.q $805AC633A82068E1, $371FE43AD04336D4, $3E017C48017AE2C5, $292045C9C672091A, $FE17193FA6FF7E78
  Data.q $24BB170DC670F1B1, $228215E7B04759EC, $8381081FD341E657, $105A57F6BD342FFB, $B487FAFAA7631800
  Data.q $02CD8258AB7E1B4C, $7FAFA533BF1272D8, $0B4E95227E4D3348, $C2283FB0F4FD51EA, $448A12D9E3719E9A
  Data.q $A9D39441710FE231, $C02226AFBB60B4BC, $BE71A320F3D6FF0F, $B80C4880C5A02FD4, $EAE80059B3FE70FC
  Data.q $BFD96D3E2109AFBE, $33433E3653923D3E, $6181FDEF7925044E, $40CCA2BCC151695B, $BFB32F995BDBE050
  Data.q $4BD80C6A38598607, $EED1229FCE4E4FFB, $37BADFD58B1931AB, $9AC9DFBE734207A8, $31180DF76E30F1B1
  Data.q $484A73B9DC7FEBCE, $D7A5B83F9D2F4FFB, $F3E8DECDC7776C64, $77EFE7474D218F98, $BEA6C0F5ABB1CE75
  Data.q $E6D34B630E33E5E9, $D1DDEBF686899CB3, $30F1B1C9EBB3E0B1, $707F829A8EE8DF2E, $EB33FE99E7EAA9A1
  Data.q $92547BE745F7507E, $CF3D5948A6BB587F, $BB773989021B3939, $EE4FFEBB1CE0C06F, $17B5C8FDB00082A9
  Data.q $0D85E5765D9A9161, $D2CFBB3D8776A515, $B091079EAE8A2450, $58699FAF38C60FA6, $AAAC44AE240825E7
  Data.q $524EF9BCCF8048DA, $7CE63B71E6C2BC56, $B1F0FBBCC0BA9B3D, $B389F106710FE236, $E0B19105F4D4FFA4
  Data.q $4964FB2AA2BB5124, $96EF9053D965946A, $5542B5438A9C7B97, $AA218C9B953A9172, $F504091819AC204F
  Data.q $19C68C085CE323C7, $0AFC1667EBA1393B, $9132FEBD1DB62678, $0A88495AE54CAD78, $974C713C10AF0B93
  Data.q $C7A92409E9132188, $DA1DCE5A182B5934, $00FF3496B3E99DD4, $C5E52BD0901E71B2, $444E454900000000
  Data.b $AE, $42, $60, $82
  end_img_info:
EndDataSection

// Subject adjusted (Kiffi)
Last edited by mestnyi on Wed Dec 06, 2023 10:10 am, edited 1 time in total.
SMaag
Enthusiast
Enthusiast
Posts: 105
Joined: Sat Jan 14, 2023 6:55 pm

Re: CatchImage does not work (was: image)

Post by SMaag »

Your Datas are of a corrupted PNG Image

if you use correct PNG Data it works
Try with

Code: Select all

; UseJPEGImageDecoder() 
; UseJPEG2000ImageDecoder() 
 UsePNGImageDecoder() 
; UseTIFFImageDecoder() 
; UseTGAImageDecoder() 
; UseGIFImageDecoder() 


img = CatchImage( #PB_Any, ?img_info, ?end_img_info - ?img_info )

Debug IsImage(img)



;      DataSection
;        img_info: 
;        IncludeBinary #PB_Compiler_Home + "examples/sources/Data/Background.bmp"
;        end_img_info:
;      EndDataSection

DataSection
  img_info:
   Data.q $0A1A0A0D474E5089,$524448490D000000,$1000000010000000,$FFF31F0000000608,$4144490203000061,$7490039254DA7854,$FF31BEC3CF461447,$AB63976DB6DB15B5,$C6DB6DB6DB629610,$E9D0F33D8C599ADA,$5D2BE7BCD3AEE938,$AFD8607FDF6B38F6,$DF27F4DD0ED47F45,$AFEE7A3F5CFE870B,$0D0FB29B066B854D,$C8F0FFCC6B7D7F47,$DFCEFFEEB26EDD7C,$5D8FF75EAB606D07,$7630B895B43B6C2F,$7AB4F8857F2A78B2,$2F958C5DBCC5F89B,$A5BC42C513E9D317,$1E8EF0B3B9E032B6,$060775C7C3005FFD,$9DC5739988E1F9F6,$2F393EE263C507A5,$399217C5338BCF10,$B859854789A8A171,$FC37D5150F871443,$5BEA2E9112D75BAF,$7B8DE8D5B8626C67,$193DE6B770DCF605,$E171546323F12CF0,$ADD150784D2F05A6,$A3BB5CB8930BD12F,$03171A2B55EC7B6A,$EB5AE06EFB8D28A8,$8F2307E4B7EB1D80,$907297E3F4A9569F,$5619A14A33C82436,$38F6DF1409B1682A,$B1BABCCD4F49C089,$0D7781B31C7572EA,$A9BA51AA4D144F74,$442568F85D0897A7,$6125EBA42B6AAE3B,$761BD1F8AB415898,$6F437523D5E6E4F3,$7828AFC4DBCDBF5B,$1363D4125203C369,$2512026C86C2FC01,$34519580D160A788,$DA8EA9B7513315AD,$F828EB310BAE12D1,$02102B3C81810D01,$03C9619448458AEA,$B5A1A5A835E60371,$6CB949D0E9456B0D,$00BF8A60CA7030C7,$9A803560924A02CA,$25942CF9072E408D,$5B11996062B3054E,$F6D6268CF9F41737,$1B4901C8258A1416
    Data.q $6608D1F82A182AB4,$245402C508A64157,$3C2B4C25E5A53A2D,$8233D357C66256A5,$B10A31202664050D,$AC4FEA7A408F8801,$32055C9022C42F19,$CB0658EC9D5CE9CC,$E67C1E2E32AC7FF6,$B07284592DCAD33D,$09C98A4A4965243C,$21878814A6E438C9,$D24593D24D6F5921,$23DD4A7E1013C79F,$AF1DCAD1A5C7F07D,$2ABD4D90CD6457BF,$D2166A43CCC869A5,$6B0DC965418C9033,$8E68FB98B8F39335,$935CB3C2F4BEE992,$C95EF7A2F359002A,$55BC1A49B3FCF0BD,$60A8415B9A0DD8F6,$959B776540F4E0EA,$977D49A6E7B19952,$F6450076FF8FD9BB,$589F97773D6F0033,$1B6DFB69CA1F7CEA,$475C23A017D3AE08,$29E3380A97D1B1D4,$28CAEA44371136F8,$FFCEEBD6785EB7CB,$FAE978DC1F1EFE02,$1572DAC06C0FE40D,$337A966EDB11ABA2,$33F5B6FCF1D5D3E2,$F30007AB23EFBA0A,$005BBE4B64F0760F,$AE444E4549000000
    Data.b $42,$60,$82
  end_img_info:
EndDataSection

mestnyi
Addict
Addict
Posts: 995
Joined: Mon Nov 25, 2013 6:41 am

Re: CatchImage does not work (was: image)

Post by mestnyi »

this code works on Mac OS

Code: Select all

UsePNGImageDecoder( )

If OpenWindow(0, 100, 100, 500, 300, "PureBasic - Image")
   
   img = CatchImage( #PB_Any, ?img_info, ?end_img_info - ?img_info )
   Debug "image "+ IsImage(img)
   
   ImageGadget(0,10,10,100,100, ImageID(img))
   
   Repeat
      Event = WaitWindowEvent()
   Until Event = #PB_Event_CloseWindow 
   
   
   
   DataSection
      img_info:
      ; size : 1404 bytes
      Data.q $0A1A0A0D474E5089, $524448490D000000, $2800000028000000, $B8FE8C0000000608, $474B62060000006D
      Data.q $A0FF00FF00FF0044, $493105000093A7BD, $5F98CD8558544144, $3B3BBFC71C47144C, $54C0F03D7F7BB707
      Data.q $14DA0D5AD0348C10, $7C1A6360A90B6D6D, $6D03CAADF49898D3, $D1A87D7AD262545F, $B69B5F469AA9349A
      Data.q $680D82AB6C37D269, $A6220B47FA51A890, $DECFEE38E105102A, $053FB87D333B772E, $CCDD3CF850EE114A
      Data.q $0766FDFE767ECCDC, $F476DC569948E258, $5BCA94AD89227ADA, $3C10B9638C15E085, $7A59504C89240017
      Data.q $8055B371E2774802, $2E678FEAA9A17AFC, $06961711C3AC7F58, $EF905DD4CA91A322, $A159B0EAD38F5EA2
      Data.q $4D30000CA9417358, $1A3033484098DD06, $2C671601A343EB08, $EDD3F547A138B820, $DAFB560A82C89ABE
      Data.q $2E1D2C863E5562A8, $3CD50AAB359173CC, $8D8C00262FCE6397, $83FB0DA43FD7D187, $DDAAFF5D74F85C02
      Data.q $B3A477582D666357, $45754E5D9B42C73C, $16732AAEDD894565, $41FBABA3A6B0899B, $3FAB16311F45A424
      Data.q $8FDB82C66F4B707F, $1595D6EF9001DD5F, $69B32B24BD2B2529, $EA0DEEB7E6181FDC, $9D9F369A5BB6326
      Data.q $A94FBDAEC7BBE0B7, $A732EAE5951BF5F4, $5C114204D2DD216D, $6B9C344C651BD9B9, $5F8FDB82CE66FAAA
      Data.q $5F57EDFEF90841DD, $8469F486ECB61D52, $C2634777AE971D35, $2A9E9FF5E072D5DC, $8DE85A9CB3A47758
      Data.q $4DCF559EDB963737, $0D1DD74741182C67, $C9DDD550E5F86C71, $E68DAFB555E65365, $79E522B2BAF36858
      Data.q $B2DAC765C78001C9, $8DAFB573522C2B62, $8F9455C8929B2E4E, $77B1059330B54E5C, $D579F26E672AD4E3
      Data.q $AC8D0E0F2BD2BD5F, $9F9532F8021F1304, $C910838758FEB56E, $816E0DF732515957, $DAAF81036D5F2CA9
      Data.q $C2E305A5E54F66D7, $73EED922E79850D2, $88B9E6F02BB0E0D9, $2241697952FB2AA2, $B51C5D50B8ACB1A3
      Data.q $69322368555B297F, $A654FC089009A54C, $1E34DD1B45EE65EE, $5F9F7579224403B7, $416D440905240B59
      Data.q $244059B47C668BBE, $56F2A644DDF22B00, $1EBC77E473482920, $E3DCB126CD5175A7, $E720A4816B952854
      Data.q $AA1C1F8C97DBB0A8, $3CE0A0A481CA0015, $2829A74C5DCDCD5F, $0F5481799C981CD6, $9356B8BCB2A56E0A
      Data.q $0B4C0AC3821950B0, $6188962AC4914B75, $8326E2692ED8B632, $32112C58C9006044, $ECE858E5B0989D1A
      Data.q $743677B1BE616735, $07BA4027E44A0623, $6C80F60B188E13D1, $829201DC00066B09, $8C96858E8E2EC9A6
      Data.q $805AC633A82068E1, $371FE43AD04336D4, $3E017C48017AE2C5, $292045C9C672091A, $FE17193FA6FF7E78
      Data.q $24BB170DC670F1B1, $228215E7B04759EC, $8381081FD341E657, $105A57F6BD342FFB, $B487FAFAA7631800
      Data.q $02CD8258AB7E1B4C, $7FAFA533BF1272D8, $0B4E95227E4D3348, $C2283FB0F4FD51EA, $448A12D9E3719E9A
      Data.q $A9D39441710FE231, $C02226AFBB60B4BC, $BE71A320F3D6FF0F, $B80C4880C5A02FD4, $EAE80059B3FE70FC
      Data.q $BFD96D3E2109AFBE, $33433E3653923D3E, $6181FDEF7925044E, $40CCA2BCC151695B, $BFB32F995BDBE050
      Data.q $4BD80C6A38598607, $EED1229FCE4E4FFB, $37BADFD58B1931AB, $9AC9DFBE734207A8, $31180DF76E30F1B1
      Data.q $484A73B9DC7FEBCE, $D7A5B83F9D2F4FFB, $F3E8DECDC7776C64, $77EFE7474D218F98, $BEA6C0F5ABB1CE75
      Data.q $E6D34B630E33E5E9, $D1DDEBF686899CB3, $30F1B1C9EBB3E0B1, $707F829A8EE8DF2E, $EB33FE99E7EAA9A1
      Data.q $92547BE745F7507E, $CF3D5948A6BB587F, $BB773989021B3939, $EE4FFEBB1CE0C06F, $17B5C8FDB00082A9
      Data.q $0D85E5765D9A9161, $D2CFBB3D8776A515, $B091079EAE8A2450, $58699FAF38C60FA6, $AAAC44AE240825E7
      Data.q $524EF9BCCF8048DA, $7CE63B71E6C2BC56, $B1F0FBBCC0BA9B3D, $B389F106710FE236, $E0B19105F4D4FFA4
      Data.q $4964FB2AA2BB5124, $96EF9053D965946A, $5542B5438A9C7B97, $AA218C9B953A9172, $F504091819AC204F
      Data.q $19C68C085CE323C7, $0AFC1667EBA1393B, $9132FEBD1DB62678, $0A88495AE54CAD78, $974C713C10AF0B93
      Data.q $C7A92409E9132188, $DA1DCE5A182B5934, $00FF3496B3E99DD4, $C5E52BD0901E71B2, $444E454900000000
      Data.b $AE, $42, $60, $82
      end_img_info:
   EndDataSection
EndIf

End
Olli
Addict
Addict
Posts: 1071
Joined: Wed May 27, 2020 12:26 pm

Re: CatchImage does not work (was: image)

Post by Olli »

Does the Smaag code work fine on Mac ?
Fred
Administrator
Administrator
Posts: 16522
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: CatchImage does not work (was: image)

Post by Fred »

May be the macos decoder is more tolerant, be sure your PNG is not corrupted.
Mindphazer
Enthusiast
Enthusiast
Posts: 338
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: CatchImage does not work (was: image)

Post by Mindphazer »

On my Mac, your first code doesn't work (IsImage() returns 0)

And the last code (the one you say it works on MacOS) displays a little part of the image
MacBook Pro 14" M1 Pro - 16 Gb - MacOS 13 - Iphone 13 Pro Max - iPad at home
...and unfortunately... Windows at work...
Mindphazer
Enthusiast
Enthusiast
Posts: 338
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: CatchImage does not work (was: image)

Post by Mindphazer »

Olli wrote: Tue Dec 05, 2023 7:28 pm Does the Smaag code work fine on Mac ?
Yes
MacBook Pro 14" M1 Pro - 16 Gb - MacOS 13 - Iphone 13 Pro Max - iPad at home
...and unfortunately... Windows at work...
mestnyi
Addict
Addict
Posts: 995
Joined: Mon Nov 25, 2013 6:41 am

Re: CatchImage does not work (was: image)

Post by mestnyi »

Mindphazer wrote: Tue Dec 05, 2023 8:59 pm On my Mac, your first code doesn't work (IsImage() returns 0)
correct because you need to uncomment "UsePNGImageDecoder( )"
Mindphazer wrote: Tue Dec 05, 2023 8:59 pm And the last code (the one you say it works on MacOS) displays a little part of the image
that's right it is
mestnyi
Addict
Addict
Posts: 995
Joined: Mon Nov 25, 2013 6:41 am

Re: CatchImage does not work (was: image)

Post by mestnyi »

Fred wrote: Tue Dec 05, 2023 8:12 pm May be the macos decoder is more tolerant, be sure your PNG is not corrupted.
how to do this?
Mindphazer
Enthusiast
Enthusiast
Posts: 338
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: CatchImage does not work (was: image)

Post by Mindphazer »

mestnyi wrote: Tue Dec 05, 2023 9:07 pm correct because you need to uncomment "UsePNGImageDecoder( )"
Ooooops yes true
MacBook Pro 14" M1 Pro - 16 Gb - MacOS 13 - Iphone 13 Pro Max - iPad at home
...and unfortunately... Windows at work...
Post Reply