当前位置: 首页>>代码示例>>Python>>正文


Python ctypes.c_byte方法代码示例

本文整理汇总了Python中ctypes.c_byte方法的典型用法代码示例。如果您正苦于以下问题:Python ctypes.c_byte方法的具体用法?Python ctypes.c_byte怎么用?Python ctypes.c_byte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ctypes的用法示例。


在下文中一共展示了ctypes.c_byte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _compute_type

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def _compute_type(self):
        if not (self.header.dwCaps & DDSEnums.DDSCAPS_TEXTURE):
            raise FormatNotValid("Invalid format file not tagged as texture")

        if self.header.dwCaps2 & DDSEnums.DDSCAPS2_CUBEMAP:
            if self.ext_header.arraySize > 1:
                self.type = DDSTexture.Type.TextureCubeArray
                self.array_size = self.ext_header.arraySize
            else:
                self.type = DDSTexture.Type.TextureCube
                self.array_size = 1
        # We either have a single texture or a texture array ( 2D )
        else:
            if self.format_code == DDSEnums.DX10_CC and \
                            self.ext_header.arraySize > 1:
                self.type = DDSTexture.Type.Texture2DArray
                self.array_size = self.ext_header.arraySize
            else:
                self.type = DDSTexture.Type.Texture2D
                self.array_size = 1

    # Loads the texture from the filename, obtaining
    # data - array of c_byte containing untouched texture data formatted matching the surfaces data
    # surfaces - metadata for the raw texture data that describes how it can be read, its valued are ready for DirectX11 creation ( Pitch, width, height, size )
    # format - DXGI compatible format the integer self.format can be safely static_cast<DXGI_FORMAT> to obtain the C++ enumerator counterpart 
开发者ID:ubuntunux,项目名称:PyEngine3D,代码行数:27,代码来源:DDSLoader.py

示例2: _getEventInformation

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def _getEventInformation(record):
        """
        Initially we are handed an EVENT_RECORD structure. While this structure technically contains
        all of the information necessary, TdhGetEventInformation parses the structure and simplifies it
        so we can more effectively parse and handle the various fields.

        :param record: The EventRecord structure for the event we are parsing
        :return: Returns a pointer to a TRACE_EVENT_INFO structure or None on error.
        """
        info = ct.POINTER(tdh.TRACE_EVENT_INFO)()
        buffer_size = wt.DWORD()

        # Call TdhGetEventInformation once to get the required buffer size and again to actually populate the structure.
        status = tdh.TdhGetEventInformation(record, 0, None, None, ct.byref(buffer_size))
        if tdh.ERROR_INSUFFICIENT_BUFFER == status:
            info = ct.cast((ct.c_byte * buffer_size.value)(), ct.POINTER(tdh.TRACE_EVENT_INFO))
            status = tdh.TdhGetEventInformation(record, 0, None, info, ct.byref(buffer_size))

        if tdh.ERROR_SUCCESS != status:
            raise ct.WinError(status)

        return info 
开发者ID:fireeye,项目名称:pywintrace,代码行数:24,代码来源:etw.py

示例3: simxGetVisionSensorImage

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def simxGetVisionSensorImage(clientID, sensorHandle, options, operationMode):
    '''
    Please have a look at the function description/documentation in the V-REP user manual
    '''

    resolution = (ct.c_int*2)()
    c_image  = ct.POINTER(ct.c_byte)()
    bytesPerPixel = 3
    if (options and 1) != 0:
        bytesPerPixel = 1
    ret = c_GetVisionSensorImage(clientID, sensorHandle, resolution, ct.byref(c_image), options, operationMode)

    reso = []
    image = []
    if (ret == 0):
        image = [None]*resolution[0]*resolution[1]*bytesPerPixel
        for i in range(resolution[0] * resolution[1] * bytesPerPixel):
            image[i] = c_image[i]
        for i in range(2):
            reso.append(resolution[i])
    return ret, reso, image 
开发者ID:Troxid,项目名称:vrep-api-python,代码行数:23,代码来源:vrep.py

示例4: io_control_file

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def io_control_file(self, io_control_code, input_buffer=None, output_buffer_length=None):
		io_status_block = wintypes.IO_STATUS_BLOCK()
		input_buffer_length = (0 if input_buffer is None else len(input_buffer))
		if output_buffer_length is None:
			output_buffer = None
			output_buffer_length = 0
		else:
			output_buffer = (ctypes.c_byte * output_buffer_length)()
		value = m_ntdll.NtDeviceIoControlFile(
			self.handle,                         # FileHandle [in]
			None,                                # Event [in-opt]
			None,                                # ApcRoutine [in-opt]
			None,                                # ApcContext [in-opt]
			ctypes.byref(io_status_block),       # IoStatusBlock [out]
			io_control_code,                     # IoControlCode [in]
			input_buffer,                        # InputBuffer [in-opt]
			input_buffer_length,                 # InputBufferLength [in]
			output_buffer,                       # OutputBuffer [out-opt]
			output_buffer_length                 # OutputBufferLength [out]
		)
		return (value, mayhem.utilities.ctarray_to_bytes(output_buffer)) 
开发者ID:zeroSteiner,项目名称:mayhem,代码行数:23,代码来源:windows.py

示例5: traces

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def traces(self) -> bytearray:
        aux_begin = self.pt_buffer.aux_buf.addr
        aux_end = self.pt_buffer.aux_buf.addr + self.pt_buffer.aux_buf.size
        for ev in self.pt_buffer.events():
            if ev.type == PerfRecord.PERF_RECORD_ITRACE_START:
                self._itrace_start_event = ev
                break

        tail = aux_begin + self.pt_buffer.header.aux_tail
        head = aux_begin + self.pt_buffer.header.aux_head
        assert tail == aux_begin
        assert head < aux_end
        length = head - tail
        buf = bytearray(length)
        c_buf = (ct.c_byte * length).from_buffer(buf)
        ct.memmove(c_buf, tail, length)

        return buf 
开发者ID:hase-project,项目名称:hase,代码行数:20,代码来源:snapshot.py

示例6: open_vm

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def open_vm(self, vmx_path, timeout=4):
        assert self.connected, "VixConnection not connected"

        start_time = time.time()
        job_handle = vixlib.VixVM_Open(self._host_handle, vmx_path, None, None)
        vm_handle = vixlib.VixHandle()

        job_completed = ctypes.c_byte(0)
        while not job_completed.value:
            err = vixlib.VixJob_CheckCompletion(job_handle, ctypes.byref(job_completed))
            _check_job_err_code(err)

            if timeout and timeout < (time.time() - start_time):
                raise VixException("Timeout (%d seconds) waiting to open VM by VMX '%s'", 0, timeout, vmx_path)

        err = vixlib.Vix_GetProperties(job_handle,
                                       vixlib.VIX_PROPERTY_JOB_RESULT_HANDLE,
                                       ctypes.byref(vm_handle),
                                       vixlib.VIX_PROPERTY_NONE)
        vixlib.Vix_ReleaseHandle(job_handle)
        _check_job_err_code(err)

        return VixVM(vm_handle) 
开发者ID:guardicore,项目名称:vmware_guest_auth_bypass,代码行数:25,代码来源:vixutils.py

示例7: shmem_as_ndarray

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def shmem_as_ndarray(raw_array):
    _ctypes_to_numpy = {
        ctypes.c_char: np.int8,
        ctypes.c_wchar: np.int16,
        ctypes.c_byte: np.int8,
        ctypes.c_ubyte: np.uint8,
        ctypes.c_short: np.int16,
        ctypes.c_ushort: np.uint16,
        ctypes.c_int: np.int32,
        ctypes.c_uint: np.int32,
        ctypes.c_long: np.int32,
        ctypes.c_ulong: np.int32,
        ctypes.c_float: np.float32,
        ctypes.c_double: np.float64
    }
    dtype = _ctypes_to_numpy[raw_array._type_]

    # The following works too, but occasionally raises
    # RuntimeWarning: Item size computed from the PEP 3118 buffer format string does not match the actual item size.
    # and appears to be slower.
    # return np.ctypeslib.as_array(raw_array)

    return np.frombuffer(raw_array, dtype=dtype) 
开发者ID:pytroll,项目名称:pyresample,代码行数:25,代码来源:_multi_proc.py

示例8: is_ipv6

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def is_ipv6(ip):
    try:
        if os.name == "nt":
            class sockaddr(ctypes.Structure):
                _fields_ = [("sa_family", ctypes.c_short),
                            ("__pad1", ctypes.c_ushort),
                            ("ipv4_addr", ctypes.c_byte * 4),
                            ("ipv6_addr", ctypes.c_byte * 16),
                            ("__pad2", ctypes.c_ulong)]

            WSAStringToAddressA = ctypes.windll.ws2_32.WSAStringToAddressA
            addr = sockaddr()
            addr.sa_family = socket.AF_INET6
            addr_size = ctypes.c_int(ctypes.sizeof(addr))
            if WSAStringToAddressA(ip, socket.AF_INET6, None, ctypes.byref(addr), ctypes.byref(addr_size)) != 0:
                raise socket.error(ctypes.FormatError())
            return ctypes.string_at(addr.ipv6_addr, 16)
        else:
            return socket.inet_pton(socket.AF_INET6, ip)
    except:
        return False 
开发者ID:bwall,项目名称:ircsnapshot,代码行数:23,代码来源:ircsnapshot.py

示例9: _reset_state

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def _reset_state(self, vk, layout, scan):
        """Clears the internal kernel keyboard state.

        This method will remove all dead keys from the internal state.

        :param int vk: The virtual key code.

        :param layout: The keyboard layout.

        :param int scan: The scan code of the key.
        """
        state = (ctypes.c_byte * 255)()
        out = (ctypes.wintypes.WCHAR * 5)()
        while self._ToUnicodeEx(
                vk, scan, ctypes.byref(state), ctypes.byref(out),
                len(out), 0, layout) < 0:
            pass 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:19,代码来源:win32.py

示例10: write_to_buffer

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def write_to_buffer(buffer, data, offset=0):
        if isinstance(buffer, ctypes.POINTER(ctypes.c_byte)):
            ctypes.memmove(buffer, data, len(data))
            return

        if offset == 0:
            buffer.value = data
        else:
            buffer.value = buffer.raw[0:offset] + data 
开发者ID:wbond,项目名称:oscrypto,代码行数:11,代码来源:_ffi.py

示例11: byte_array

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def byte_array(byte_string):
        return (ctypes.c_byte * len(byte_string))(*bytes_to_list(byte_string)) 
开发者ID:wbond,项目名称:oscrypto,代码行数:4,代码来源:_ffi.py

示例12: ref

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def ref(value, offset=0):
        if offset == 0:
            return ctypes.byref(value)
        return ctypes.cast(ctypes.addressof(value) + offset, ctypes.POINTER(ctypes.c_byte)) 
开发者ID:wbond,项目名称:oscrypto,代码行数:6,代码来源:_ffi.py

示例13: native

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def native(type_, value):
        if isinstance(value, type_):
            return value
        if sys.version_info < (3,) and type_ == int and isinstance(value, int_types):
            return value
        if isinstance(value, ctypes.Array) and value._type_ == ctypes.c_byte:
            return ctypes.string_at(ctypes.addressof(value), value._length_)
        return type_(value.value) 
开发者ID:wbond,项目名称:oscrypto,代码行数:10,代码来源:_ffi.py

示例14: cf_number_to_number

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def cf_number_to_number(value):
        """
        Converts a CFNumber object to a python float or integer

        :param value:
            The CFNumber object

        :return:
            A python number (float or integer)
        """

        type_ = CoreFoundation.CFNumberGetType(_cast_pointer_p(value))
        c_type = {
            1: c_byte,              # kCFNumberSInt8Type
            2: ctypes.c_short,      # kCFNumberSInt16Type
            3: ctypes.c_int32,      # kCFNumberSInt32Type
            4: ctypes.c_int64,      # kCFNumberSInt64Type
            5: ctypes.c_float,      # kCFNumberFloat32Type
            6: ctypes.c_double,     # kCFNumberFloat64Type
            7: c_byte,              # kCFNumberCharType
            8: ctypes.c_short,      # kCFNumberShortType
            9: ctypes.c_int,        # kCFNumberIntType
            10: c_long,             # kCFNumberLongType
            11: ctypes.c_longlong,  # kCFNumberLongLongType
            12: ctypes.c_float,     # kCFNumberFloatType
            13: ctypes.c_double,    # kCFNumberDoubleType
            14: c_long,             # kCFNumberCFIndexType
            15: ctypes.c_int,       # kCFNumberNSIntegerType
            16: ctypes.c_double,    # kCFNumberCGFloatType
        }[type_]
        output = c_type(0)
        CoreFoundation.CFNumberGetValue(_cast_pointer_p(value), type_, byref(output))
        return output.value 
开发者ID:wbond,项目名称:oscrypto,代码行数:35,代码来源:_core_foundation_ctypes.py

示例15: LOBYTE

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_byte [as 别名]
def LOBYTE(a): return (ctypes.c_byte)(a) 
开发者ID:Wyliodrin,项目名称:pybass,代码行数:3,代码来源:pybass.py


注:本文中的ctypes.c_byte方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。