LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-02-2006, 07:49 PM   #1
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Rep: Reputation: 30
Xlib question


Hi,
In Xlib, how do you create a transparent background textbox in g++ or gcc and stick it onto an image. I used the following code, hope you can extend it

Code snippet:

struct jpeg_decompress_struct cinfo;
FILE *infile;
JSAMPARRAY buffer;
int row_stride, lines = 0, total_size;
unsigned char *buf_tmp;

if ((infile = fopen ("test.jpg", "rb")) == NULL)
return NULL;

// if (setjmp (jerr.setjmp_buffer)) {
// jpeg_destroy_decompress(&cinfo);
// jpeg_destroy_decompress(&cinfo);
// fclose(infile);
// return 0;
// }

jpeg_create_decompress(&cinfo);
jpeg_stdio_src (&cinfo, infile);

(void) jpeg_read_header(&cinfo, TRUE);
(void) jpeg_start_decompress(&cinfo);
row_stride = cinfo.output_width * cinfo.output_components;

total_size = row_stride * cinfo.output_height;

buffer = (*cinfo.mem->alloc_sarray)
((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1);

// read the file into memory, no need to display it
buf_tmp = (unsigned char *) malloc (total_size * sizeof(char));

while (cinfo.output_scanline < cinfo.output_height) {
(void) jpeg_read_scanlines (&cinfo, buffer, 1);
memcpy (buf_tmp, buffer[0], row_stride);
buf_tmp += row_stride;
lines++;
}

// Add a Text Label here, with transparent background
// The text Label is the photo timestamp, then save it back
(void) jpeg_finish_decompress(&cinfo);
jpeg_destroy_decompress(&cinfo);

fclose(infile);
 
Old 01-02-2006, 07:54 PM   #2
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Original Poster
Rep: Reputation: 30
or something looks like textout in VCPP/Win?
Thanks
Jack
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
xlib question lucky6969b Programming 10 12-29-2005 09:09 PM
Xlib and images question SciYro Programming 2 06-14-2005 12:29 PM
Xlib question memory_leak Programming 0 12-05-2003 10:05 AM
Xlib question me01 Programming 0 09-26-2003 04:56 PM
Xlib-Windows Manager question amilici Programming 1 09-11-2003 11:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration