Visual C++ :: Draw Grid Over Bitmap In Scrollview

Jul 5, 2013

I have a CScrollView that displays a bitmap and I'm trying to draw a grid that I can turn off and on by check box and when the mouse is over a section of the grid that square highlights... I do all the drawing in the ondraw function... But when I have many grid squares it becomes slow to scroll and to highlight the square the mouse is over... I'm not sure the best way to go about this and where to place code to speed it up... The bitmap is only loaded once... But in ondraw the grid has to redraw every time scrolled and when mouse moved over a square.. In onmousemove I call invalidate so the square under mouse changes...

View 5 Replies


ADVERTISEMENT

C :: Draw A Grid Using The Characters?

Aug 20, 2013

I'm trying to create a grid using the following characters: !, @, #, $, &.

It's an 8 x 8 grid, and should contain the characters in no particular order (trying to create a Bejeweled-like game).

I already defined the width and length to be 8, so:

#define WIDTH 8
#define LENGTH 8

Code:

void makegrid(char grid[])
{
int j;
int k;
for ( j = -1; j < LENGTH; j++ )
{
for ( k = -1; k < WIDTH; k++ )
{
/* I don't know what to type here anymore :( */
}
} }

View 14 Replies View Related

C++ :: Draw 2D Grid With Blank Cells?

Mar 21, 2014

I am trying to draw a 2d grid array for a battleships game. I need the grid to have a border around each cell, how to do this. so far my code is:

#include<iostream>
using namespace std;
int main(){
int grid[5][5] = {{0}};

[Code] .....

View 4 Replies View Related

C/C++ :: Draw A 5x5 Grid For Battleships Game

Mar 20, 2014

I'm trying to draw a 5x5 grid for a battleships game.

How to draw the grid with borders and individual cells.

I'm using dev c++

View 14 Replies View Related

C/C++ :: Trying To Draw A Grid In A Square For Simple Checkers Game

Oct 7, 2014

I am trying to draw a grid for checkers. I could draw a square at the starting point from origin with the code below(attached the pic below how it looks) however I am not being able to draw a grid when the program runs.

#include "ccc_win.h"
// GameDemo.cpp
// Shows how to place a piece accurately on a grid after a mouse click.
#include "ccc_win.h" // for graphics classes and functions
using namespace std;
int ccc_win_main(void) // main function for graphics program

[Code] ....

View 3 Replies View Related

Visual C++ :: Loading Bitmap In Particular Way?

May 25, 2013

I have a function that essentially takes a screen shot and saves a pointer to it as a structure. I would like to use the same structure for bitmaps that I load from files.

Code:
typedef struct _BITMAPCAPTURE {
HBITMAP hbm;
LPDWORD pixels;
INT width;
INT height;
} BITMAPCAPTURE;
BOOL CaptureScreen(BITMAPCAPTURE* bmpCapture) {

[code].....

The handle to the bitmap, as well as the width and height are all easy enough to get but I'm unsure of how to get the pixels.

View 2 Replies View Related

Visual C++ :: Use Bitmap On Button Instead Of Text

Dec 15, 2013

I'm trying to create a dialog where some of the buttons have pictures on them, rather than plain text. I notice that under the button's properties, under the "styles" tab there's a checkbox "bitmap". I can't seem to find any easy way of setting a bitmap.

View 4 Replies View Related

Visual C++ :: Slow Performances Using Bitmap / GDI

Apr 17, 2014

I am trying to do this:

while(1)
{
CaptureScreenshot (as BMP)
Convert screenshot to 24 bit instead of 32 bit
Resize screenshot size
Get the BMP bits array of the resized screenshot
}

I have it working but the best i could get is 18 iteration (screenshots) per second. This is what i do:

Code:
Start() {
ULONG_PTR gdiplusToken=0;
HDC mhCompatibleDC;
HBITMAP mhCompatibleBitmap;
HWND mhDesktopWnd;
HDC mhDesktopDC;
byte*piRGB=new byte[1200*900*3]

[Code] .....

Here i do things with piRGB but these things are not counted it the timer so you can assume here the code ends . As said as the code looks now, i can fill piRGB ~18 times (18loops) in 1 second. I must improve that...

View 14 Replies View Related

Visual C++ :: How To Save Bitmap To File

May 19, 2014

I have this code, where I capture window and make copy to bitmap of it. I am working on rotation of bitmap. But my problem is that when I save the image to file the result is just a black screen. It looks like there could be some problem either in GdipCreateBitmapFromHBITMAP() or GdipGetImageGraphicsContext()

How to fix it and to get the rotated image?

Code:
// CODE 81 and 82 de facto no difference
#defineCODE85 // 81
#defineWINDOW_MIN_HEIGHT200

[Code].....

View 14 Replies View Related

Visual C++ :: Drawing Text On A Bitmap?

Oct 5, 2012

I wrote a simple clock that shows the time over bitmap as follows:

Code:
void CMyClock::OnPaint()
{
CRect rect;
GetClientRect(&rect);

[Code]....

Now I got rid off the white border but everytime I draw a text it write on top of the previous text so after few seconds everything is a mess and the time is no longer readable.

View 5 Replies View Related

Visual C++ :: SDI CView Covered With Bitmap Resource?

Feb 10, 2013

I have an SDI / CView app (VS 2010). All works well until I minimize the app using the minimize button or drag it partially off of the screen. In the former instance, any attempt to restore the app results in an appcrash with a tight freeze up of the machine. In the later instance the same happens immediately.

In building the app, I scoured the web for code to accomplish the loading and display of the bitmap. After some experimentation I settled on overriding the OnPaint. Below is the code. Note that m_Map is a CBitmap member and IDB_BITMAP1 is a loaded bitmap resource.

Code:

void CMyDragViewView::OnPaint()
{
// CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CView::OnPaint() for painting messages
// http://msgroups.net/microsoft.public.vc.mfc/loading-bitmaps-into-main-window/563285
int x = m_Map.LoadBitmap(IDB_BITMAP1);
TRACE1(" x = %d
", x);
CPaintDC* dc = new CPaintDC(this);

[code]....

I suspect that the problem is OnPaint trying to repaint the bitmap which requires reloading it, but I don't know how to work around this.

View 3 Replies View Related

Visual C++ :: Using 2D Array - Displaying Bitmap Image With Scrolling

Mar 11, 2014

My requirement is,

Read *.bmp image and displaying bitmap image with scrollbar in a MFC dialog application.

I was done using this

I was read the *.bmp image as a pixel data and stored by 2D Array,

Now i want to Display this 2D array as bitmap image with scrollbar separately in the same dialog. How can i display bitmap with scrollbar using 2D array?

View 10 Replies View Related

Visual C++ :: Bitmap Display From Buffer Received By TCP Socket

Feb 6, 2013

I want to display my image on window without saving it.

When data is received window size changes but there is no display on window.

My Code is:

Code:

int iBufferLength;
int iEnd;
int iSpaceRemaining;
int i;
iBufferLength = iSpaceRemaining = sizeof(chIncomingDataBuffer);
iEnd = 0;
iSpaceRemaining -= iEnd;

[code].....

where I'm doing wrong?

View 1 Replies View Related

Visual C++ :: Analyze Bitmap - Concept For Saving Data

May 18, 2014

I would like to create program which will analyse bitmap so would need good concept to save data. I am interested about the theory and I realize that i must to think this carefully because bad concept could create insufficient memory or inefficient program. Basically I want my program work with HSV or HSL model so I would need to convert the bitmap to HSL, but I am not sure if I should convert it first and then analyse all pixels or should I start to analyse the bitmap and make the conversion to HSL during it. But my main question is what method to choose to save the data in memory.

Even that I would start with very small, it should work also with bigger image like image having 1200 or even 4200 px on height. So the program should first analyse all columns of pixels in the image so for example 1200x800 px image has 1200 columns. So I would like to know if is it possible to create such object which would have such structure like this

Obj->basicColumnData->black->columns[name]->group

and in the place of columns should be placed data for every column. I would look for groups of pixels in the column, so in the result the column x could bear e.g. 500 groups of information and every group should contain the range of pixels e.g. group 1 should contain y value from 0 to 20, group 2 should contain value from 25-27 and so on. So I would create 1200 columns bear many of groups. This would be contained in "black" or "white" member to contain the data. This is just simplified idea, but the whole object should contain next data not just basicColumnData... So there should be another members bearing information calculated from the selected data.

So my question is what kind of method of saving data use for this? Should I use heap and dynamic allocated memory or should I create custom class, which will define every member, but these members will have to be dynamic memory? With the dynamic memory is there problem that there could be not enough memory to create such big object?

View 5 Replies View Related

Visual C++ :: Frozen Grid In CView Of SDI Splitter

Sep 14, 2013

I have been working with both Chris Mander's MFC grid and the Ultimate Grid.

See for details:

The Ultimate Grid Beginner's Guide By The Ultimate Toolbox, 25 Aug 2007 : [URL] ....

MFC Grid control 2.27 By Chris Maunder, 6 May 2010 : [URL] ....

Both of these grid controls work nicely in a SDI CView windows. But when I create a split window using CSplitterWnd and the following code in an attempt to create a split window with a CListView and and a CView using this code:

Code:
// in CMainFrame.h
// Attributes
public:
CSplitterWnd m_wndSplitter;
//..
// in CMainFrame.cpp
//..
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)

[Code] .....

The grid in the CView window appears but is frozen in both instances. I suspect there is some notification necessary to for the grid to send and receive messages from the split CView window, but I cannot figure out how to implement this notification.

Unfortunately, even a demo application would be too large to append, but for anyone that is interested, the split method is encapsulated in the code I've presented here and the implementation of both grid controls is well explained in the links provided.

View 6 Replies View Related

Visual C++ :: Draw Buffer With Raw Data?

Nov 19, 2012

Got buffer with raw data. How to display it in MFC dialog and refresh it?

View 3 Replies View Related

Visual C++ :: How To Draw 2D Array Of Data In MFC

Jun 3, 2013

I have a circle of data that is represented as:

vector<vector <unsigned char> >* data;

The first dimension of this vector is the angle of the data so there are 360 angles, and the second dimension is the bins of the data in which there are 512 bins per angle. Each bin has a value from 0 to 15 to determine the intensity of the bin. So basically, when this is all display, there will be a circle of data, with varying colors of intensity at each bin.

What is the best approach to doing this in MFC? How to draw this on the screen?

View 12 Replies View Related

Visual C++ :: Draw Image Using 2D Byte Array?

Feb 8, 2013

I like to Draw an Image Using two dimensional byte array[512][256].

I used SetPixelV method to plot the image.

But Its very slow & hidden some buttons(Controls) at run time in the same dialog.

For reference i send some code,

Code:
for(row = 0; row <512; row ++)
{
for(col = 0; col < 256; col++)
{
Data[row][col] = y;
SetPixelV(d, 10+row, 10+col, RGB(Data[row][col],Data[row][col],Data[row][col]));
}
}

View 14 Replies View Related

Visual C++ :: Draw Multiple Lines And Move Them On Screen

Jul 28, 2013

I am writing a pure C based win32 applications. I have drawn line. Now i want to translate that line, move the line whereved user wants to move on screen. Then again I drawn another line, I am drawing multiple lines.

I have created rectangle region for each line and trying to move the line.

When I move the 2nd line over the 1st line on screen the 1st line is getting wiped out. Because I am InvalidateRect() of the rect for the line being moved, so when that rectangle is crossing the other line then the other line is getting removed from the screen.

How can I rectify it. How can I have all the lined being on the screen and moved according to the user's wish. The code should be pure C and win32 no MFC.

View 4 Replies View Related

Visual C++ :: How To Draw Pixel-level Color Gradients In CScrollView

Oct 6, 2012

i wish to plot a mathematical function on a 2-dimensional grid. The function will be represented by 3 sets of floats, x-values, y-values, and z-values. Obviously, it is impossible to plot 3 such data sets on a 2D grid, so one approach is to use pixel coloration to represent the z-values.

Those examples (and there are many to be found) show something like the function of the complex variable z, f(z) = exp(z). I have attached a exp(z).jpg example of the imaginary part of the plot exp(z).

My question is: How to accomplish such a gradient colorization, assuming one already has the data?

I have experimented with Gdiplus SetPixel, but I have not figured out how to produce a smooth gradient.

Here's my attempt to create a simple gradient:

Code:
CDC * pDC = GetDC();
Graphics graphics(pDC->m_hDC);
CRect r;
GetWindowRect(&r);
ScreenToClient(&r);

[Code] ....

View 1 Replies View Related

Visual C++ :: Draw A Shape Or Font On Dialog And Then Fill The Outline?

Jul 8, 2013

I am trying to draw a shape or font on dialog and then fill the outline. I have 2 buttons on this 2 buttons I have the following code

Code:
case IDC_BUTTON1:
MessageBox(hDlg, L"Start Drawing!!", L"ButtonPressed", MB_OK | MB_ICONEXCLAMATION);
hDC = GetDC(hDlg);
brush = CreateSolidBrush(RGB(128, 128, 128));
SelectObject(hDC, brush);

[code].....

When I remove the BeginPath() and EndPath() functions my lines are being drawn. But when I insert this BeginPath() and EndPath() and StrokeAndFillPath(hDC); the nothing is being drawn.

Why it is not doing as per the expectations. I want to draw a shape for example A with a outline. And i want it to be closed when drawing is ended and filled the hollow portion.

What am I doing wrong in this ?I am not implementing it in WM_PAINT but drawing is done in WM_LBUTTONUP.

View 6 Replies View Related

Visual C++ :: Line Graph Using Single Line Values From Bitmap

Feb 3, 2014

I was loaded a bmp file in my mfc window and stored rgb data in a file.My image size is 320x240.

Is possible to pick a single point (location) from that bmp image (Not the whole window)?

i like to plot a line graph using the pointed single line data using the stored file data?

here R is X Axis and G & B is Y Axis.

If i have 2D array of data means how can i plot the line graph?

View 4 Replies View Related

C# :: Bitmap To Desktop?

Mar 24, 2014

I've been using code that takes a bitmap and then changes the color:

private void GetPixel(Bitmap ProcessedBitmap)
{
unsafe
{

[Code].....

Instead of using a Bitmap image (jpg, png, etc), I would like to use the desktop. I'm trying to scan my desktop for a pixel color using lockbits (GetPixel was way too slow.). I also do not wish to change the color of anything, I just want to loop until the pixel is found (with my getpixel method, I just put an if/then statement in the for loop). Something like:

if((CurrentPixel.R == 0xff) && (CurrentPixel.G == 0xff) && (CurrentPixel.B == 0xff)) Then
MsgBox("Pixel Found!")

View 3 Replies View Related

C :: Resize A Bitmap Image

Aug 22, 2014

I am trying to re-size a bitmap image for a class.They gave us two options to use to do the program with: an array or move the file position indicator. I want to use the file option. All the bitmap header info is checking out. The file after being re-sized should be 822 bytes but it is 1.6 KiB and the image is distorted.

Code:

#include <stdint.h>
/**
* Common Data Types
*
* The data types in this section are essentially aliases for C/C++
* primitive data types.

[Code]...

View 2 Replies View Related

C++ :: How Does SDL Load Bitmap Images

Apr 8, 2013

I don't mean how do I load a bmp, I mean how does SDL manage to do this?

View 2 Replies View Related

C++ :: Bitmap To Word Document

Jan 7, 2014

How to draw a rectangle and covert to an image and that image saved into word file?

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved