4 Byte String to int32 Conversion

Hi, this might be an easy question, but a OS X Declare needs a int32 value which is generated somehow from a 4 byte char like “BGRA”.
How can I achieve this in Xojo?

Probably. Can you elaborate a little more on which function you are trying to create the declare for, and where you are seeing this 4 byte char so we can help you better?

Sure, sorry

https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/index.html#//apple_ref/c/func/CGDisplayStreamCreate

CGDisplayStreamRef CGDisplayStreamCreate ( CGDirectDisplayID display, size_t outputWidth, size_t outputHeight, int32_t pixelFormat, CFDictionaryRef properties, CGDisplayStreamFrameAvailableHandler handler );

under description of pixelFormat:

[quote]The desired Core Media pixel format of the output frame data. The value must be one of the following:
‘BGRA’: Packed Little Endian ARGB8888
‘l10r’: Packed Little Endian ARGB2101010
‘420v’: 2-plane “video” range YCbCr 4:2:0
‘420f’: 2-plane “full” range YCbCr 4:2:0[/quote]

create a constant
enter ‘BGRA’ as the value and make sure its a numeric type
done

[quote=200432:@Norman Palardy]create a constant
enter ‘BGRA’ as the value and make sure its a numeric type
done[/quote]

I am not sure if I did this correctly
But I get an error.

ah
Like this

Thank you Norman! This solved my problem.

BTW: Funny thing is you can’t type ’ ’ in the Default Value textfield with german keyboard it always converts it into a lower ’ and an upper '. Very annoying.

You want to look in the Keyboard/Text preferences, on the right “for single quotes”, where you can set it to ‘abc’.

The other way to do this without using a constant is using the magic of memoryblocks :stuck_out_tongue:

    dim mb as new memoryblock(4)
    mb.LittleEndian = false
    mb.StringValue(0,4) = "BGRA"
    constPixelFormat = mb.Int32Value(0)