Merge remote branch 'upstream/master'
This commit is contained in:
commit
0742eb4ecb
@ -51,6 +51,11 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
set(CMAKE_INSTALL_LIBDIR "lib")
|
||||
endif()
|
||||
|
||||
# build shared libs
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
endif()
|
||||
|
||||
# Compiler-specific flags
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-unused-but-set-variable")
|
||||
@ -138,3 +143,4 @@ endif()
|
||||
|
||||
add_subdirectory(client)
|
||||
add_subdirectory(server)
|
||||
add_subdirectory(keymaps)
|
||||
|
@ -25,7 +25,7 @@ set(CLIPRDR_SRCS
|
||||
cliprdr_main.h
|
||||
)
|
||||
|
||||
add_library(cliprdr SHARED ${CLIPRDR_SRCS})
|
||||
add_library(cliprdr ${CLIPRDR_SRCS})
|
||||
set_target_properties(cliprdr PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(cliprdr freerdp-utils)
|
||||
|
@ -25,7 +25,7 @@ set(DRDYNVC_SRCS
|
||||
dvcman.h
|
||||
)
|
||||
|
||||
add_library(drdynvc SHARED ${DRDYNVC_SRCS})
|
||||
add_library(drdynvc ${DRDYNVC_SRCS})
|
||||
set_target_properties(drdynvc PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(drdynvc freerdp-utils)
|
||||
|
@ -23,7 +23,7 @@ set(RAIL_SRCS
|
||||
rail_orders.c
|
||||
rail_orders.h)
|
||||
|
||||
add_library(rail SHARED ${RAIL_SRCS})
|
||||
add_library(rail ${RAIL_SRCS})
|
||||
set_target_properties(rail PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(rail freerdp-utils)
|
||||
|
@ -21,7 +21,7 @@ set(RDPDBG_SRCS
|
||||
rdpdbg_main.c
|
||||
)
|
||||
|
||||
add_library(rdpdbg SHARED ${RDPDBG_SRCS})
|
||||
add_library(rdpdbg ${RDPDBG_SRCS})
|
||||
set_target_properties(rdpdbg PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(rdpdbg freerdp-utils)
|
||||
|
@ -30,7 +30,7 @@ set(RDPDR_SRCS
|
||||
rdpdr_main.h
|
||||
)
|
||||
|
||||
add_library(rdpdr SHARED ${RDPDR_SRCS})
|
||||
add_library(rdpdr ${RDPDR_SRCS})
|
||||
set_target_properties(rdpdr PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(rdpdr freerdp-utils)
|
||||
|
@ -25,7 +25,7 @@ set(DISK_SRCS
|
||||
|
||||
include_directories(..)
|
||||
|
||||
add_library(disk SHARED ${DISK_SRCS})
|
||||
add_library(disk ${DISK_SRCS})
|
||||
set_target_properties(disk PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(disk freerdp-utils)
|
||||
|
@ -33,7 +33,7 @@ endif()
|
||||
|
||||
include_directories(..)
|
||||
|
||||
add_library(printer SHARED ${PRINTER_SRCS})
|
||||
add_library(printer ${PRINTER_SRCS})
|
||||
set_target_properties(printer PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(printer freerdp-utils)
|
||||
|
@ -22,7 +22,7 @@ set(RDPSND_SRCS
|
||||
rdpsnd_main.h
|
||||
)
|
||||
|
||||
add_library(rdpsnd SHARED ${RDPSND_SRCS})
|
||||
add_library(rdpsnd ${RDPSND_SRCS})
|
||||
set_target_properties(rdpsnd PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(rdpsnd freerdp-utils)
|
||||
|
@ -24,7 +24,7 @@ set(RDPSND_ALSA_SRCS
|
||||
include_directories(..)
|
||||
include_directories(${ALSA_INCLUDE_DIRS})
|
||||
|
||||
add_library(rdpsnd_alsa SHARED ${RDPSND_ALSA_SRCS})
|
||||
add_library(rdpsnd_alsa ${RDPSND_ALSA_SRCS})
|
||||
set_target_properties(rdpsnd_alsa PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(rdpsnd_alsa freerdp-utils)
|
||||
|
@ -24,7 +24,7 @@ set(RDPSND_PULSE_SRCS
|
||||
include_directories(..)
|
||||
include_directories(${PULSE_INCLUDE_DIRS})
|
||||
|
||||
add_library(rdpsnd_pulse SHARED ${RDPSND_PULSE_SRCS})
|
||||
add_library(rdpsnd_pulse ${RDPSND_PULSE_SRCS})
|
||||
set_target_properties(rdpsnd_pulse PROPERTIES PREFIX "")
|
||||
|
||||
target_link_libraries(rdpsnd_pulse freerdp-utils)
|
||||
|
@ -58,7 +58,7 @@ static void rdpsnd_pulse_context_state_callback(pa_context* context, void* userd
|
||||
|
||||
case PA_CONTEXT_FAILED:
|
||||
case PA_CONTEXT_TERMINATED:
|
||||
DEBUG_SVC("state %d", (int)state);
|
||||
DEBUG_SVC("PA_CONTEXT_FAILED/PA_CONTEXT_TERMINATED %d", (int)state);
|
||||
pa_threaded_mainloop_signal(pulse->mainloop, 0);
|
||||
break;
|
||||
|
||||
@ -224,13 +224,21 @@ static void rdpsnd_pulse_open(rdpsndDevicePlugin* device, rdpsndFormat* format)
|
||||
{
|
||||
rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)device;
|
||||
pa_stream_state_t state;
|
||||
pa_buffer_attr buffer_attr = { 0 };
|
||||
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
|
||||
|
||||
if (!pulse->context || pulse->stream)
|
||||
if (!pulse->context || pulse->stream) {
|
||||
DEBUG_WARN("pulse stream has been created.");
|
||||
return;
|
||||
}
|
||||
|
||||
rdpsnd_pulse_set_format_spec(pulse, format);
|
||||
|
||||
if (pa_sample_spec_valid(&pulse->sample_spec) == 0) {
|
||||
pa_sample_spec_snprint(ss, sizeof(ss), &pulse->sample_spec);
|
||||
DEBUG_WARN("Invalid sample spec %s", ss);
|
||||
return;
|
||||
}
|
||||
|
||||
pa_threaded_mainloop_lock(pulse->mainloop);
|
||||
pulse->stream = pa_stream_new(pulse->context, "freerdp",
|
||||
&pulse->sample_spec, NULL);
|
||||
@ -241,17 +249,15 @@ static void rdpsnd_pulse_open(rdpsndDevicePlugin* device, rdpsndFormat* format)
|
||||
pa_context_errno(pulse->context));
|
||||
return;
|
||||
}
|
||||
|
||||
/* install essential callbacks */
|
||||
pa_stream_set_state_callback(pulse->stream,
|
||||
rdpsnd_pulse_stream_state_callback, pulse);
|
||||
pa_stream_set_write_callback(pulse->stream,
|
||||
rdpsnd_pulse_stream_request_callback, pulse);
|
||||
buffer_attr.maxlength = (uint32_t) -1;
|
||||
buffer_attr.tlength = (uint32_t) -1; /* pa_usec_to_bytes(2000000, &pulse->sample_spec); */
|
||||
buffer_attr.prebuf = (uint32_t) -1;
|
||||
buffer_attr.minreq = (uint32_t) -1;
|
||||
buffer_attr.fragsize = (uint32_t) -1;
|
||||
|
||||
if (pa_stream_connect_playback(pulse->stream,
|
||||
pulse->device_name, &buffer_attr, 0, NULL, NULL) < 0)
|
||||
pulse->device_name, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL) < 0)
|
||||
{
|
||||
pa_threaded_mainloop_unlock(pulse->mainloop);
|
||||
DEBUG_WARN("pa_stream_connect_playback failed (%d)",
|
||||
@ -452,7 +458,10 @@ int FreeRDPRdpsndDeviceEntry(PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints)
|
||||
data = pEntryPoints->plugin_data;
|
||||
if (data && strcmp((char*)data->data[0], "pulse") == 0)
|
||||
{
|
||||
if(strlen((char*)data->data[1]) > 0)
|
||||
pulse->device_name = xstrdup((char*)data->data[1]);
|
||||
else
|
||||
pulse->device_name = NULL;
|
||||
}
|
||||
|
||||
pulse->mainloop = pa_threaded_mainloop_new();
|
||||
|
@ -17,5 +17,14 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
file(GLOB HEADERS "freerdp/*")
|
||||
file(GLOB HEADERS "freerdp/*.h")
|
||||
install_files(/include/freerdp FILES ${HEADERS})
|
||||
|
||||
install(DIRECTORY freerdp/utils DESTINATION include/freerdp FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY freerdp/chanman DESTINATION include/freerdp FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY freerdp/cache DESTINATION include/freerdp FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY freerdp/gdi DESTINATION include/freerdp FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY freerdp/kbd DESTINATION include/freerdp FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY freerdp/rali DESTINATION include/freerdp FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY freerdp/rfx DESTINATION include/freerdp FILES_MATCHING PATTERN "*.h")
|
||||
install(DIRECTORY freerdp/plugins DESTINATION include/freerdp FILES_MATCHING PATTERN "*.h")
|
||||
|
@ -27,7 +27,7 @@ enum RDP_CODEC_ID
|
||||
{
|
||||
CODEC_ID_NONE = 0x00,
|
||||
CODEC_ID_NSCODEC = 0x01,
|
||||
CODEC_ID_REMOTEFX = 0x02
|
||||
CODEC_ID_REMOTEFX = 0x03
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -98,6 +98,7 @@ struct _RFX_CONTEXT
|
||||
|
||||
/* temporary data within a frame */
|
||||
uint32 frame_idx;
|
||||
boolean header_processed;
|
||||
uint8 num_quants;
|
||||
uint32* quants;
|
||||
uint8 quant_idx_y;
|
||||
@ -124,6 +125,7 @@ FREERDP_API void rfx_context_set_pixel_format(RFX_CONTEXT* context, RFX_PIXEL_FO
|
||||
FREERDP_API RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, STREAM* data_in);
|
||||
FREERDP_API void rfx_message_free(RFX_CONTEXT* context, RFX_MESSAGE* message);
|
||||
|
||||
FREERDP_API void rfx_compose_message_header(RFX_CONTEXT* context, STREAM* data_out);
|
||||
FREERDP_API void rfx_compose_message(RFX_CONTEXT* context, STREAM* data_out,
|
||||
const RFX_RECT* rects, int num_rects, uint8* image_data, int width, int height, int rowstride);
|
||||
|
||||
|
27
include/freerdp/utils/bitmap.h
Normal file
27
include/freerdp/utils/bitmap.h
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Bitmap File Format Utils
|
||||
*
|
||||
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __UTILS_BITMAP_H
|
||||
#define __UTILS_BITMAP_H
|
||||
|
||||
#include <freerdp/api.h>
|
||||
|
||||
FREERDP_API void freerdp_bitmap_write(char* filename, void* data, int width, int height, int bpp);
|
||||
|
||||
#endif /* __UTILS_BITMAP_H */
|
3
keymaps/CMakeLists.txt
Normal file
3
keymaps/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
install(FILES aliases amiga ataritt empty evdev fujitsu hp ibm macintosh macosx sony sun xfree86 xfree98 xkb.pl DESTINATION share/freerdp/keymaps)
|
||||
install(DIRECTORY digital_vndr DESTINATION share/freerdp/keymaps FILES_MATCHING PATTERN "*")
|
||||
install(DIRECTORY sgi_vndr DESTINATION share/freerdp/keymaps FILES_MATCHING PATTERN "*")
|
@ -26,7 +26,7 @@ set(FREERDP_CACHE_SRCS
|
||||
glyph.c
|
||||
cache.c)
|
||||
|
||||
add_library(freerdp-cache SHARED ${FREERDP_CACHE_SRCS})
|
||||
add_library(freerdp-cache ${FREERDP_CACHE_SRCS})
|
||||
|
||||
set_target_properties(freerdp-cache PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
|
||||
|
||||
|
@ -21,7 +21,7 @@ set(FREERDP_CHANMAN_SRCS
|
||||
libchanman.c
|
||||
libchanman.h)
|
||||
|
||||
add_library(freerdp-chanman SHARED ${FREERDP_CHANMAN_SRCS})
|
||||
add_library(freerdp-chanman ${FREERDP_CHANMAN_SRCS})
|
||||
|
||||
set_target_properties(freerdp-chanman PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
|
||||
target_link_libraries(freerdp-chanman freerdp-utils)
|
||||
|
@ -92,7 +92,7 @@ set(LIBFREERDP_CORE_SRCS
|
||||
peer.h
|
||||
)
|
||||
|
||||
add_library(freerdp-core SHARED ${LIBFREERDP_CORE_SRCS})
|
||||
add_library(freerdp-core ${LIBFREERDP_CORE_SRCS})
|
||||
|
||||
set_target_properties(freerdp-core PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
|
||||
|
||||
|
@ -34,7 +34,7 @@ set(FREERDP_GDI_SRCS
|
||||
shape.c
|
||||
gdi.c)
|
||||
|
||||
add_library(freerdp-gdi SHARED ${FREERDP_GDI_SRCS})
|
||||
add_library(freerdp-gdi ${FREERDP_GDI_SRCS})
|
||||
|
||||
target_link_libraries(freerdp-gdi freerdp-cache)
|
||||
target_link_libraries(freerdp-gdi freerdp-rfx)
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <freerdp/freerdp.h>
|
||||
#include <freerdp/constants.h>
|
||||
#include <freerdp/gdi/color.h>
|
||||
#include <freerdp/utils/bitmap.h>
|
||||
#include <freerdp/rfx/rfx.h>
|
||||
|
||||
#include <freerdp/gdi/dc.h>
|
||||
@ -754,11 +755,14 @@ void gdi_cache_brush(rdpUpdate* update, CACHE_BRUSH_ORDER* cache_brush)
|
||||
brush_put(gdi->cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp);
|
||||
}
|
||||
|
||||
int tilenum = 0;
|
||||
|
||||
void gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_command)
|
||||
{
|
||||
int i, j;
|
||||
int tx, ty;
|
||||
STREAM* s;
|
||||
char* tile_bitmap;
|
||||
RFX_MESSAGE* message;
|
||||
GDI* gdi = GET_GDI(update);
|
||||
RFX_CONTEXT* context = (RFX_CONTEXT*) gdi->rfx_context;
|
||||
@ -771,6 +775,8 @@ void gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_comm
|
||||
surface_bits_command->width, surface_bits_command->height,
|
||||
surface_bits_command->bitmapDataLength);
|
||||
|
||||
tile_bitmap = xzalloc(32);
|
||||
|
||||
if (surface_bits_command->codecID == CODEC_ID_REMOTEFX)
|
||||
{
|
||||
s = stream_new(0);
|
||||
@ -790,6 +796,11 @@ void gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_comm
|
||||
|
||||
gdi_image_convert(message->tiles[i]->data, gdi->tile->bitmap->data, 64, 64, 32, 32, gdi->clrconv);
|
||||
|
||||
#ifdef DUMP_REMOTEFX_TILES
|
||||
sprintf(tile_bitmap, "/tmp/rfx/tile_%d.bmp", tilenum++);
|
||||
freerdp_bitmap_write(tile_bitmap, gdi->tile->bitmap->data, 64, 64, 32);
|
||||
#endif
|
||||
|
||||
for (j = 0; j < message->num_rects; j++)
|
||||
{
|
||||
gdi_SetClipRgn(gdi->primary->hdc,
|
||||
@ -824,6 +835,11 @@ void gdi_surface_bits(rdpUpdate* update, SURFACE_BITS_COMMAND* surface_bits_comm
|
||||
|
||||
gdi_image_convert(message->tiles[i]->data, gdi->tile->bitmap->data, 64, 64, 32, 32, gdi->clrconv);
|
||||
|
||||
#ifdef DUMP_REMOTEFX_TILES
|
||||
sprintf(tile_bitmap, "/tmp/rfx/tile_%d.bmp", tilenum++);
|
||||
freerdp_bitmap_write(tile_bitmap, gdi->tile->bitmap->data, 64, 64, 32);
|
||||
#endif
|
||||
|
||||
gdi_BitBlt(gdi->primary->hdc, tx, ty, 64, 64, gdi->tile->hdc, 0, 0, GDI_SRCCOPY);
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ set(FREERDP_KBD_SRCS
|
||||
libkbd.c
|
||||
libkbd.h)
|
||||
|
||||
add_library(freerdp-kbd SHARED ${FREERDP_KBD_SRCS})
|
||||
add_library(freerdp-kbd ${FREERDP_KBD_SRCS})
|
||||
|
||||
find_suggested_package(XKBFile)
|
||||
if(XKBFILE_FOUND)
|
||||
|
@ -23,7 +23,7 @@ set(FREERDP_RAIL_SRCS
|
||||
icon.c
|
||||
rail.c)
|
||||
|
||||
add_library(freerdp-rail SHARED ${FREERDP_RAIL_SRCS})
|
||||
add_library(freerdp-rail ${FREERDP_RAIL_SRCS})
|
||||
|
||||
set_target_properties(freerdp-rail PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
|
||||
|
||||
|
@ -39,7 +39,7 @@ set(LIBFREERDP_RFX_SRCS
|
||||
librfx.c
|
||||
)
|
||||
|
||||
add_library(freerdp-rfx SHARED ${LIBFREERDP_RFX_SRCS})
|
||||
add_library(freerdp-rfx ${LIBFREERDP_RFX_SRCS})
|
||||
|
||||
set_target_properties(freerdp-rfx PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
|
||||
|
||||
|
@ -625,7 +625,7 @@ static void rfx_compose_message_context(RFX_CONTEXT* context, STREAM* data_out)
|
||||
context->properties = properties;
|
||||
}
|
||||
|
||||
static void rfx_compose_message_header(RFX_CONTEXT* context, STREAM* data_out)
|
||||
void rfx_compose_message_header(RFX_CONTEXT* context, STREAM* data_out)
|
||||
{
|
||||
stream_check_size(data_out, 12 + 10 + 12 + 13);
|
||||
|
||||
@ -633,6 +633,8 @@ static void rfx_compose_message_header(RFX_CONTEXT* context, STREAM* data_out)
|
||||
rfx_compose_message_context(context, data_out);
|
||||
rfx_compose_message_codec_versions(context, data_out);
|
||||
rfx_compose_message_channels(context, data_out);
|
||||
|
||||
context->header_processed = True;
|
||||
}
|
||||
|
||||
static void rfx_compose_message_frame_begin(RFX_CONTEXT* context, STREAM* data_out)
|
||||
@ -831,7 +833,7 @@ FREERDP_API void rfx_compose_message(RFX_CONTEXT* context, STREAM* data_out,
|
||||
const RFX_RECT* rects, int num_rects, uint8* image_data, int width, int height, int rowstride)
|
||||
{
|
||||
/* Only the first frame should send the RemoteFX header */
|
||||
if (context->frame_idx == 0)
|
||||
if (context->frame_idx == 0 && !context->header_processed)
|
||||
rfx_compose_message_header(context, data_out);
|
||||
|
||||
rfx_compose_message_data(context, data_out, rects, num_rects, image_data, width, height, rowstride);
|
||||
|
@ -24,8 +24,9 @@ set(LIBFREERDP_RFX_SSE2_SRCS
|
||||
|
||||
include_directories(..)
|
||||
|
||||
add_library(freerdp-rfx-sse2 STATIC ${LIBFREERDP_RFX_SSE2_SRCS})
|
||||
add_library(freerdp-rfx-sse2 ${LIBFREERDP_RFX_SSE2_SRCS})
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||
set_target_properties(freerdp-rfx-sse2 PROPERTIES COMPILE_FLAGS "-fPIC")
|
||||
endif()
|
||||
install(TARGETS freerdp-rfx-sse2 DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
@ -25,6 +25,7 @@ set(FREERDP_UTILS_SRCS
|
||||
blob.c
|
||||
dsp.c
|
||||
event.c
|
||||
bitmap.c
|
||||
hexdump.c
|
||||
list.c
|
||||
load_plugin.c
|
||||
@ -46,7 +47,7 @@ set(FREERDP_UTILS_SRCS
|
||||
|
||||
add_definitions(-DPLUGIN_PATH="${FREERDP_PLUGIN_PATH}")
|
||||
|
||||
add_library(freerdp-utils SHARED ${FREERDP_UTILS_SRCS})
|
||||
add_library(freerdp-utils ${FREERDP_UTILS_SRCS})
|
||||
|
||||
set_target_properties(freerdp-utils PROPERTIES VERSION ${FREERDP_VERSION_FULL} SOVERSION ${FREERDP_VERSION} PREFIX "lib")
|
||||
|
||||
|
105
libfreerdp-utils/bitmap.c
Normal file
105
libfreerdp-utils/bitmap.c
Normal file
@ -0,0 +1,105 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Client
|
||||
* Bitmap File Format Utils
|
||||
*
|
||||
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <freerdp/types.h>
|
||||
|
||||
#include <freerdp/utils/bitmap.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8 magic[2];
|
||||
} bmpfile_magic;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 filesz;
|
||||
uint16 creator1;
|
||||
uint16 creator2;
|
||||
uint32 bmp_offset;
|
||||
} bmpfile_header;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 header_sz;
|
||||
sint32 width;
|
||||
sint32 height;
|
||||
uint16 nplanes;
|
||||
uint16 bitspp;
|
||||
uint32 compress_type;
|
||||
uint32 bmp_bytesz;
|
||||
sint32 hres;
|
||||
sint32 vres;
|
||||
uint32 ncolors;
|
||||
uint32 nimpcolors;
|
||||
} BITMAPINFOHEADER;
|
||||
|
||||
void freerdp_bitmap_write(char* filename, void* data, int width, int height, int bpp)
|
||||
{
|
||||
FILE* fp;
|
||||
bmpfile_magic magic;
|
||||
bmpfile_header header;
|
||||
BITMAPINFOHEADER info_header;
|
||||
|
||||
fp = fopen(filename, "w+b");
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
printf("failed to open file %s\n", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
magic.magic[0] = 'B';
|
||||
magic.magic[1] = 'M';
|
||||
|
||||
header.creator1 = 0;
|
||||
header.creator2 = 0;
|
||||
|
||||
header.bmp_offset =
|
||||
sizeof(bmpfile_magic) +
|
||||
sizeof(bmpfile_header) +
|
||||
sizeof(BITMAPINFOHEADER);
|
||||
|
||||
info_header.bmp_bytesz = width * height * (bpp / 8);
|
||||
|
||||
header.filesz =
|
||||
header.bmp_offset +
|
||||
info_header.bmp_bytesz;
|
||||
|
||||
info_header.width = width;
|
||||
info_header.height = (-1) * height;
|
||||
info_header.nplanes = 1;
|
||||
info_header.bitspp = bpp;
|
||||
info_header.compress_type = 0;
|
||||
info_header.hres = width;
|
||||
info_header.vres = height;
|
||||
info_header.ncolors = 0;
|
||||
info_header.nimpcolors = 0;
|
||||
info_header.header_sz = sizeof(BITMAPINFOHEADER);
|
||||
|
||||
fwrite((void*) &magic, sizeof(bmpfile_magic), 1, fp);
|
||||
fwrite((void*) &header, sizeof(bmpfile_header), 1, fp);
|
||||
fwrite((void*) &info_header, sizeof(BITMAPINFOHEADER), 1, fp);
|
||||
fwrite((void*) data, info_header.bmp_bytesz, 1, fp);
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ STREAM* stream_new(int size)
|
||||
if (size != 0)
|
||||
{
|
||||
size = size > 0 ? size : 0x400;
|
||||
stream->data = (uint8*)xmalloc(size);
|
||||
stream->data = (uint8*)xzalloc(size);
|
||||
stream->p = stream->data;
|
||||
stream->size = size;
|
||||
}
|
||||
@ -55,10 +55,13 @@ void stream_free(STREAM* stream)
|
||||
|
||||
void stream_extend(STREAM* stream, int request_size)
|
||||
{
|
||||
int increased_size;
|
||||
int pos;
|
||||
|
||||
pos = stream_get_pos(stream);
|
||||
stream->size += (request_size > stream->size ? request_size : stream->size);
|
||||
increased_size = (request_size > stream->size ? request_size : stream->size);
|
||||
stream->size += increased_size;
|
||||
stream->data = (uint8*)xrealloc(stream->data, stream->size);
|
||||
stream_set_pos(stream, pos);
|
||||
memset(stream->p, 0, increased_size);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user