Jump to content
  • Advertisement
Sign in to follow this  
ehguacho

[.net] blitting problems...

This topic is 3020 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi! i'm having problems with blitting images. i'm trying to dissect an image into several 8x8 tiles. this is the code i get so far:
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace blits
{
    public partial class Form1 : Form
    {
        [System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
        private static extern int BitBlt
        (
            IntPtr hdcDest,     // handle to destination DC (device context)
            int nXDest,         // x-coord of destination upper-left corner
            int nYDest,         // y-coord of destination upper-left corner
            int nWidth,         // width of destination rectangle
            int nHeight,        // height of destination rectangle
            IntPtr hdcSrc,      // handle to source DC
            int nXSrc,          // x-coordinate of source upper-left corner
            int nYSrc,          // y-coordinate of source upper-left corner
            System.Int32 dwRop  // raster operation code
        );
        
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Bitmap Imagen = new Bitmap("D:\\Pajaro\\Programacion\\blits\\tileset.jpg");
            pictureBox1.Image = Imagen;
            Graphics Gfx = Graphics.FromImage(Imagen);
            IntPtr hdcSrc = Gfx.GetHdc();
            Graphics Gfx2 = pictureBox2.CreateGraphics();
            IntPtr hdcDest = Gfx2.GetHdc();
            BitBlt(hdcDest, 0, 0, 8, 8, hdcSrc, 0, 0, 0xCC0020);
            Gfx.ReleaseHdc();
            Gfx.Dispose();
            Gfx2.ReleaseHdc();
            Gfx2.Dispose();
        }
    }
}
as you can see, i have some graphics data stored into Gfx2. but how i can put that data into a PictureBox control? any suggestion will help! thank you all in advance! [Edited by - ehguacho on April 11, 2010 4:42:47 PM]

Share this post


Link to post
Share on other sites
Advertisement
The best way to put anything in a PictureBox Control is by blitting to a bitmap and then setting the Image property of the PictureBox

Share this post


Link to post
Share on other sites
Quote:
Original post by ernow
The best way to put anything in a PictureBox Control is by blitting to a bitmap and then setting the Image property of the PictureBox

sorry, i don't know how to do that! ._.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!