LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-21-2008, 09:34 PM   #1
mirsoft
LQ Newbie
 
Registered: Oct 2007
Posts: 15

Rep: Reputation: 0
Red face how to draw a bitmap in the window using xlib


like the topic , how to darw a picture in the window from a bmp file. best give me some codes . i have try much times, thanks.
 
Old 01-22-2008, 01:53 PM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,287

Rep: Reputation: 173Reputation: 173
XCopyArea

bmp as in windows?

you can't, you'll need to convert it to an X pixmap
 
Old 01-23-2008, 01:55 AM   #3
mirsoft
LQ Newbie
 
Registered: Oct 2007
Posts: 15

Original Poster
Rep: Reputation: 0
yes, i convert it to ppm file, but i don't know what to do next. copy area is invalid.
 
Old 01-23-2008, 11:00 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,287

Rep: Reputation: 173Reputation: 173
XCreatePixmapFromBitmapData
XCopyArea

what have you got?
a pixmap file looks like this:

Code:
#define alien_width 16
#define alien_height 16
static unsigned char alien_bits[] = {
   0x13, 0xc8, 0xa2, 0x45, 0xc3, 0xc3, 0xe2, 0x47, 0xf3, 0xcf, 0xbe, 0x7d,
   0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x1f, 0x3f, 0xfc, 0xf2, 0x4f, 0xe3, 0xc7,
   0xc2, 0x43, 0x83, 0xc1, 0x02, 0x40, 0x03, 0xc0};
you #include it and then do something like:
Code:
#include "alien"
    r->picture = XCreatePixmapFromBitmapData(
                            global.display,
                            global.window, alien_bits,
                            alien_width, alien_height,
                            random_colour(&(r->tint)),
                            0, global.depth);

        XCopyArea ( global.display, r->picture, global.window,
                    global.gc, 0, 0, alien_width, alien_height,
                    r->p.x, r->p.y);
 
Old 01-23-2008, 06:56 PM   #5
mirsoft
LQ Newbie
 
Registered: Oct 2007
Posts: 15

Original Poster
Rep: Reputation: 0
I think you maybe create a picture from a xbm file with gray color, but i want to create a picture from a ppm file. i use XImage done this, but i feel this way is a little slow.Can you tell me a fast way?
3Q.


Mr mirsoft.
 
  


Reply

Tags
bitmap, xlib


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Fastest way to draw a 16 or 32 bit RGB bitmap in XLIB (without GL)? fcdev Programming 1 11-14-2007 03:18 AM
How does one draw pixels directly onto the window in C and Modular X.org X11R7? amitron Programming 4 10-15-2006 05:54 AM
topmost window with xlib CarzyIvan Programming 0 03-21-2006 03:18 PM
window without a title bar using xlib CarzyIvan Programming 1 02-11-2006 04:21 PM
how to draw color images with xlib? BBB Programming 19 07-15-2005 02:04 PM


All times are GMT -5. The time now is 08:30 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration