diff options
author | ToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp> | 2020-03-30 09:39:24 +0900 |
---|---|---|
committer | ToshikazuOhiwa <toshikazu_ohiwa@mail.toyota.co.jp> | 2020-03-30 09:39:24 +0900 |
commit | 91f5345046f18f406071befd62e0e05322a5a1de (patch) | |
tree | 74fb8e365988ae7aef69711a053a50045977abbd /logger_service/server/screenShot | |
parent | 706ad73eb02caf8532deaf5d38995bd258725cb8 (diff) |
ss-loggerservice branch
Diffstat (limited to 'logger_service/server/screenShot')
-rw-r--r-- | logger_service/server/screenShot/Makefile | 53 | ||||
-rw-r--r-- | logger_service/server/screenShot/ss_logger_scrshot.cpp | 89 |
2 files changed, 142 insertions, 0 deletions
diff --git a/logger_service/server/screenShot/Makefile b/logger_service/server/screenShot/Makefile new file mode 100644 index 00000000..8f801231 --- /dev/null +++ b/logger_service/server/screenShot/Makefile @@ -0,0 +1,53 @@ +# +# @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. +# +# 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. +# + +######### installed program ############# +INST_PROGS = SS_ScrShot + +######### installed library(*.a) ############# + + +######### installed shared library(*.so) ############# + + +######### install headers(*.h) ############# + + +######### compiled sources ############# +SS_ScrShot_SRCS = ss_logger_scrshot.cpp + +######### add source path ############# + + +######### add compile option ############# +CPPFLAGS += -DLINUX +CPPFLAGS += -fno-exceptions + +######### linked library ############# + + +######### linked library (dynamic) ############# +LDLIBS += -Wl,-Bdynamic -ldu +LDLIBS += -Wl,-Bdynamic -ljpeg +#LDLIBS += -Wl,-Bdynamic -lextension +LDLIBS += -Wl,-Bdynamic -lvp +LDLIBS += -Wl,-Bdynamic -ldrm + +######### add library path ############# +LDFLAGS += -Wl,--gc-sections + +LINK_CXX=Y +include ../../../system_service.mk diff --git a/logger_service/server/screenShot/ss_logger_scrshot.cpp b/logger_service/server/screenShot/ss_logger_scrshot.cpp new file mode 100644 index 00000000..d45b212e --- /dev/null +++ b/logger_service/server/screenShot/ss_logger_scrshot.cpp @@ -0,0 +1,89 @@ +/* + * @copyright Copyright (c) 2016-2019 TOYOTA MOTOR CORPORATION. + * + * 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. + */ + +/////////////////////////////////////////////////////////////////////////////// +/// \ingroup tag_SS_LoggerService +/// \brief +/// +/// +/////////////////////////////////////////////////////////////////////////////// +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <jpeglib.h> +#include <du.h> + +#define MAX_IMAGE_WIDTH 1280 +#define MAX_IMAGE_HEIGHT 480 +#define COLOR_COMPONENT 4 + +int SS_Logger_SaveScreenShot(const char* filename, int type) { + FILE *outfile; + struct SCRSHOT_capture_arg stSCR; + struct jpeg_compress_struct cinfo; + struct jpeg_error_mgr jerr; + unsigned char *work_buf; + + stSCR.du = type; // 0:E2 1:M2 + stSCR.fmt = SCRSHOT_FMT_ARGB8888; + stSCR.buff = malloc(MAX_IMAGE_WIDTH * MAX_IMAGE_HEIGHT * COLOR_COMPONENT); + stSCR.buff_len = MAX_IMAGE_WIDTH * MAX_IMAGE_HEIGHT * COLOR_COMPONENT; + stSCR.ev_handler = NULL; // sync mode + + if (stSCR.buff == NULL) { + exit(1); + } + + if (SCRSHOT_RET_SUCCESS != SCRSHOT_capture(&stSCR)) { + exit(1); + } + + cinfo.err = jpeg_std_error(&jerr); + jpeg_create_compress(&cinfo); + + if ((outfile = fopen(filename, "wb")) == NULL) { + exit(1); + } + jpeg_stdio_dest(&cinfo, outfile); + cinfo.image_width = stSCR.width; + cinfo.image_height = stSCR.height; + cinfo.input_components = COLOR_COMPONENT; + cinfo.in_color_space = JCS_EXT_BGRA; + jpeg_set_defaults(&cinfo); + jpeg_start_compress(&cinfo, TRUE); + + work_buf = (unsigned char*) stSCR.buff; + for (unsigned int i = 0; i < stSCR.height; i++) { + jpeg_write_scanlines(&cinfo, (JSAMPARRAY) & (work_buf), 1); + work_buf += stSCR.width * COLOR_COMPONENT; + } + + jpeg_finish_compress(&cinfo); + jpeg_destroy_compress(&cinfo); + free(stSCR.buff); + fclose(outfile); + exit(0); +} + +int main(int argc, char *argv[]) { + if (argc < 3) { + exit(1); + } + int chType = atoi(argv[2]); + SS_Logger_SaveScreenShot(argv[1], chType); + + return 0; +} |