Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 496737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:42:52+00:00 2026-05-13T05:42:52+00:00

I have just started learning XNA. This is my first program that I am

  • 0

I have just started learning XNA. This is my first program that I am writing as a side “fun” project.

I am having trouble drawing a bitmap that gets created to the screen.

I know the bitmap is being created correctly because when I run

bitmap.Save( @"C:\jnk\test.bmp", System.Drawing.Imaging.ImageFormat.Bmp );

it saves the correct bitmap

I am trying to display the image from a class draw function however cannot get anything to appear. I found some sources that used a System.Drawing.Graphics class to create the bitmap and it also showed it drawing it to the screen with

bitmapGraphics.DrawImage( bitmap, new System.Drawing.Point( this.boardXOffset, this.boardYOffset ) );

bitmapGraphics is a Systems.Drawing.Graphics object and the boardOffsets are both 0. I am trying to draw this from a class which is called in the draw function of my main.

However I get nothing, No errors, and no display. I am going to guess that this is because It does not know what object to draw it onto perhaps? But my lack of knowledge in xna… any help would be great.

if it helps at all the main program.cs runs this as its draw function

protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear( Color.CornflowerBlue );
BoardGraphicsEngine.Draw();
base.Draw(gameTime);
}

and the draw function in the BoardGraphicsEngine is

public void Draw( )
{

int width = Convert.ToInt32( System.Math.Ceiling( board.pixelWidth ) );
int height = Convert.ToInt32( System.Math.Ceiling( board.pixelHeight ) );
width += 1;
height += 1;

Bitmap bitmap = new Bitmap( width, height );
Graphics bitmapGraphics = Graphics.FromImage( bitmap );
Pen p = new Pen( System.Drawing.Color.Black );
SolidBrush sb = new SolidBrush( System.Drawing.Color.Black );

sb = new SolidBrush( board.boardState.backgroundColor );
bitmapGraphics.FillRectangle( sb, 0, 0, width, height );

    ... Loop through board and create with a couple calls to 
    bitmapGraphics.FillPolygon( new SolidBrush( board.hexes[i, j].hexState.BackgroundColor ), board.hexes[i, j].points );
    and
    bitmapGraphics.DrawPolygon( p, board.hexes[i, j].points );
    and
    bitmapGraphics.DrawPolygon( p, board.boardState.activeHex.points );


//bitmap.Save( @"C:\jnk\test.bmp", System.Drawing.Imaging.ImageFormat.Bmp );

bitmapGraphics.DrawImage( bitmap, new System.Drawing.Point( this.boardXOffset, this.boardYOffset ) );

        bitmapGraphics.Dispose();
        bitmap.Dispose();
    }

}

The original source for most of this is http://www.codeproject.com/KB/graphics/hexagonal_part1.aspx but part of the problem may be this example was a windows form and i’m creating an xna project

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:42:52+00:00Added an answer on May 13, 2026 at 5:42 am

    I know very little about XNA, but you’re definitely not using XNA here. You’re using the .NET interface to GDI+, and your Draw() method is rendering everything to an off-screen bitmap (bitmapGraphics), which isn’t going to show up on screen unless you render it to the screen buffer. If you want to learn XNA, I would recommend working through an XNA-specific tutorial.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started learning MySQL and am having trouble extracting matching flights from
I have just started learning Jquery and am new to writing javascript (I am
I have just started learning MVVM and having a dilemna. If I have a
I have just started learning CXF. I made a maven archetype project through eclipse.
I have just started learning Qt and compiled and executed this spinet #include <qapplication.h>
I have just started learning PHP, and here's my first doubt... Both of these
I have just started learning how to program Windows GUI's using the low level
I have just started learning wordpress plugin development and got this error when I
Just started learning Haskell. I have an empty source file with this inside: pe
I have just started learning Android and thought of a simple project to help

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.