Basic Bitmap Questions

Really stupid getting started questions

Page 1 of 1

6 Replies - 2270 Views - Last Post: 20 January 2010 - 11:27 AM Rate Topic: -----

#1 TerishD  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 19-January 10

Basic Bitmap Questions

Post icon  Posted 19 January 2010 - 12:22 PM

I want to create (NOT load) a bitmap. Alter that bitmap. Finally, attach that bitmap to a 3D mesh.

Now, believe it or not, I did that last part rather easily. DirectX tutorials can actually teach you something. It is the first part, which I would have thought to be easy, that I am having trouble with.

First, I am using Turbo C++.

Second, I could not find graphics.h or conio.h. I found a copy on the internet and downloaded it. They bombed. Both were attempting to enumerate the colors, and stepped on each other's feet. I thus removed that code from one of them.

Third, no bombing, so I put into my code -

bitmap SD;

Well, it bombed. I could not get the any recognition of bitmap as a type of variable. I tried spelling it different ways: Bitmap, bitmap, etc.

Can anyone get me started?
Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: Basic Bitmap Questions

#2 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 291
  • View blog
  • Posts: 1,900
  • Joined: 25-October 06

Re: Basic Bitmap Questions

Posted 19 January 2010 - 02:15 PM

as you don't appear to have <graphics.h> I assume you are using Turbo C V2.0 - I seem to remember only V3.0 and 3.1 come with the graphics library. As far as I am aware you cannot download <graphics.h> for V2.0

If you wish to use Turbo C bitmap I would recommend you switch to Code::Blocks
http://www.codeblocks.org/

and use the Borland Graphics Interface developed for Windows by Michael Main
http://www.cs.colora.../bgi/index.html

you can download graphics.h and libbgi.a files from
http://www.uniquenes...ate.com/devcpp/

and add them to Code::Blocks (rather than DEV C++ as the web page says)
the function calls are similar to the Turbo C graphics library

e.g. the following example which uses a bitmap worked OK
http://www.cs.colora...i/getimage.html

the updated code is
/* getimage example */

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <alloc.h>

void save_screen(void *buf[4]);
void restore_screen(void *buf[4]);
int maxx, maxy;
int main(void)
{
   int gdriver=DETECT, gmode, errorcode;
   void *ptr[4];
	initwindow(800,700,"bitmap", 300, 100, true); //open a graphics window
	setactivepage(1);
	setvisualpage(1);
   maxx = getmaxx();
   maxy = getmaxy();
   /* draw an image on the screen */
   rectangle(0, 0, maxx, maxy);
   line(0, 0, maxx, maxy);
   line(0, maxy, maxx, 0);
   save_screen(ptr);		   /* save the current screen */
   getch();					/* pause screen */
   cleardevice();			  /* clear screen */
   restore_screen(ptr);		/* restore the screen */
   getch();					/* pause screen */
   closegraph();
   return 0;
}



void save_screen(void *buf[4])
{
   unsigned size;
   int ystart=0, yend, yincr, block;
   yincr = (maxy+1) / 4;
   yend = yincr;
   /* get byte size of image */
   size = imagesize(0, ystart, maxx, yend);
   for (block=0; block<=3; block++) {
	  if ((buf[block] = malloc(size)) == NULL) {
		 closegraph();
		 printf("Error: not enough heap space in save_screen().\n");
		 exit(1);
	  }
	 getimage(0, ystart, maxx, yend, buf[block]);
	 ystart = yend + 1;
	 yend += yincr + 1;
   }
}


void restore_screen(void *buf[4])
{
   int ystart=0, yend, yincr, block;
   yincr = (maxy+1) / 4;
   yend = yincr;
   for (block=0; block<=3; block++) {
	  putimage(0, ystart, buf[block], COPY_PUT);
	  free(buf[block]);
	  ystart = yend + 1;
	  yend += yincr + 1;
   }
}


This post has been edited by horace: 19 January 2010 - 02:44 PM

Was This Post Helpful? 0
  • +
  • -

#3 debjit625  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 51
  • View blog
  • Posts: 446
  • Joined: 06-September 08

Re: Basic Bitmap Questions

Posted 19 January 2010 - 02:28 PM

For altering bitmap use GDI.Google for Windows GDI ,offcourse directx draw will also go for this job ,Now the main stuff including header files will do nothing it all about the *.lib file .A tip if you like , use VisualStudio ExpressEdition its free and VS EE 2008 comes with sdk so you will have no problems like these else for Turbo you may not have installed sdk yet or you didnt included the directories properly.

Good Luck
Was This Post Helpful? 0
  • +
  • -

#4 TerishD  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 19-January 10

Re: Basic Bitmap Questions

Posted 19 January 2010 - 03:14 PM

Horace - I did check out CodeBlock. I don't need another programming language that people look at me strangely when I say that I use it. Also, I don't want to tie myself in another college project that gets dropped when the semester is over or certain people graduate -- and I am looking for updates that never occur (then they try to make money off their work by charging me).

Oh, and no, I am not going to initwindow. Nothing gets window'ed until my code is finished with it.

debjit625 - no, I am not doing Microsoft. I have PLENTY of experience writing in Microsoft languages, and they constrain me more than they help. In business, the constraints are nice, so I understand the use in a business setting. I want my game to be something different, and Microsoft does not support different. C++ is raw enough that I can be different, but there is a learning curve. I accept that.
Was This Post Helpful? 0
  • +
  • -

#5 debjit625  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 51
  • View blog
  • Posts: 446
  • Joined: 06-September 08

Re: Basic Bitmap Questions

Posted 19 January 2010 - 03:46 PM

You said you are using DirectX (A microsoft product) and Microsofts compilers goes best with it, anyway Turbo is also not bad or in some sence its good enough try their sdk .And these questions are of game related so ask them in game forum their you will get better responce.

Good Luck
Was This Post Helpful? 0
  • +
  • -

#6 TerishD  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 19-January 10

Re: Basic Bitmap Questions

Posted 20 January 2010 - 10:49 AM

Okay, I am figuring some stuff out. The problem is that I have taken another step only to face another roadblock.

The initial answer is:
Graphics::TBitmap *PicFrom = new Graphics::TBitmap();

Okay, that gives me the variable. Now, I want to load a picture from it (again, not from a file). I would think (silly simple person that I am) -

PicFrom = Image1->Picture;

Nope. This errors out. It seems that TBitmap does not have an option to accept a value from an already existing form. Sorta like
int B;
without being able to say
B = A;
Was This Post Helpful? 0
  • +
  • -

#7 nanowire  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 107
  • Joined: 05-January 10

Re: Basic Bitmap Questions

Posted 20 January 2010 - 11:27 AM

Yes, Code::Blocks is simpler, and faster. This should be in a different forum if you ask me though...

I don't know how to say int B without B = A...

Edit:

Actually, try making a new variable.

This post has been edited by nanowire: 20 January 2010 - 11:28 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1