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
ADVERTISEMENT
Aug 27, 2013
I am writing a class which loads a bitmap image into a one dimension char* array.
This class has methods to allow for resampling and cropping the image before saving the bitmap image. It works perfectly for all images in which the width is divisible by 4. However when the width is not divisible by 4 the resulting bitmap is all mixed up.
I have spent much of the day googling this problem but to no avail. I know it is a problem with making sure the scanlines are DWORD aligned, and I believe I have done that correctly. I suspect that the problem is that I need to take the padding into account during the crop for loops but am lost to how to do this.
BTW: Coding on Linux using GCC
The following code is a cut down version from my bitmap class. I have removed methods which are not needed to make reading a little easier.
#include "BMP.h"
// FIXME (nikki#1#): Portrait bug on images of specific sizes
// TODO (nikki#1#): Memory leak checks
// THIS METHOD WRITES A BITMAP FILE FROM THE CHAR ARRAY .
bool BMP::saveBMP(string fileName, string *err) {
FILE *filePtr;
[Code]...
View 2 Replies
View Related
Mar 20, 2014
Which command should i use for displaying a jpeg image in Visual Studio 2008 (VC++)?In the past i used LoadImage function for displaying Bitmaps.
View 14 Replies
View Related
Sep 3, 2013
I would like the coded ASCII image to scroll horizontally 3 times and then end with the message:
"Hit Enter to continue or Esc to end"
If Enter is pressed, the program should then continue to scroll another 3 times and then display the same message above.
If Esc is hit then the program loop should stop similar to an escape sequence.
Here is my code that partially accomplishes my objective:
Code:
// Professor.cpp : The entry point for the console application.
#include <iostream>
#include <string>
#include <windows.h>
#include <stdlib.h>
[Code] .....
View 3 Replies
View Related
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
Jan 21, 2012
Writing a program to negate a bitmap image. The program as I have it is asking the user to input a value for the RGB values. But how do I set it up to give the negative of each colour? It has been suggested using the & operator to negate the image inside nested loops.
Also, the RGBQUAD structure was copied into my main program from a BITMAP.H file we were given. However, is it okay just to leave that in the .h file, and just call it from my main program ....if that makes sense?
Anyway, here is my code so far
#include <iostream>
#include <fstream> //Used for file I/O
#include <cstdlib> //For exit
#include <string>
#include <algorithm> // for remove_if
#include <cctype> // for iswspace
[Code] ....
View 14 Replies
View Related
Jun 27, 2013
i have to create a console based application in c language that can join and split bitmap images. the requirements of the application are as follows :
1. Split Image
Enter number of parts:
Enter source image path:
Enter destination folder:
2. Join Images (all images should be of same width and height)
Enter image path:
Join more Image (y/n):
3. Exit
Take care of following things:
- Application should show number of images processed while running.
- Acceptable Image format is BMP only.
- Application should give all the validations for correct image name, type, size, path, etc.
View 2 Replies
View Related
Feb 24, 2013
I'm trying to display an image from a stream data. But there is no image when getting image::from stream.
It's my source code:
Code:
IStream* pstream = NULL;
if(SUCCEEDED(CreateStreamOnHGlobal(NULL, TRUE, &pstream))) {
ULONG lreal = 0;
pstream->Write(chIncomingDataBuffer, iEnd, &lreal );
[Code]...
There is no image from data.
View 5 Replies
View Related
Nov 8, 2012
i want to open image in windows from application but it's not showing the image. here is my code/////
using (OpenFileDialog dlg = new OpenFileDialog())
{
dlg.InitialDirectory = "c:";
dlg.Title = "Open Image";
[Code].....
View 1 Replies
View Related
Mar 12, 2013
I m loading a png image by using the ATLImage library.
CImage Image;
Image.Load (L"D:ImagesPNG_ImagesImage7.png");
how to retrieve the byte array value of this png image. I tried retrieving it as
byte *png = reinterpret_cast<BYTE *>(Image.GetBits());
but when i access the data , der is a loss of data while converting it in the above manner.
I found a snippet in net for decoding the raw data . but der is a line is the code which is unknown to me. The code is as follows :
CImage atlImage;
HMODULE hMod = GetModuleHandle(NULL);
atlImage.Load(bstr);
void* pPixel = atlImage.GetBits();
intpitch = atlImage.GetPitch();
intdepth = atlImage.GetBPP();
[Code] ....
How do I get the byte * value form the png image loaded?
View 3 Replies
View Related
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
Jul 3, 2014
Im trying to compare the image of a button to another image in Visual Studio like so...
//variables
Image active = Image.FromFile("C:\Users\Ethan\Desktop\StarWars Status\active.png");
Image stunned = Image.FromFile("C:\Users\Ethan\Desktop\StarWars Status\stunned.png");
[Code]...
btnStatusPlr1.Image SHOULD come back as True.Then I realized it might not be the same as setting the buttons image in the properties (Which is what i did to get the original image (the one being compared to))
I do have a feeling ive done something wrong here (Yes im a noob /> )
Variable active, is the same image as the buttons default (Well should be)
View 1 Replies
View Related
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
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
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
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
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
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
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
View Related
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
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
Oct 21, 2013
I need to be able to take a bitmap e.g. "untitled.bmp" (bit depth: 24) and loop through every pixel from top left to bottom right and find the rgb (or hex) value for each pixel e.g. (255,255,255) for white and store this rgb (or hex) value in a two-dimensional array depending on its [column]and[row].
How to read bitmap data in in c++ . Also, I'm reluctant to use windows header files as I'd prefer it to be cross-platform.
View 1 Replies
View Related
Oct 14, 2013
I have screen scrolling up and running but it keeps going after the background finishes. how do you fix that?
View 4 Replies
View Related
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
Sep 19, 2013
I have screen scrolling working but i want to have text scroll with the screen. because at the moment my player moves and the screen scrolls but the text doesn't.
View 15 Replies
View Related
Mar 5, 2013
You are programming a sideways scrolling shooter. This used 2D cell based maps that are very long (over 100,000 characters per row long, 24 rows of 40 characters on screen), and the only way you can get them to fit in memory is to compress each row of the map using run length encoding and to decompress each new column of the map on the right of the screen as the background moves from right to left. You maintain a list of pointers into the RLE data for each row of the screen. Columns that are scrolled off the left are discarded. This works very well and the game only just fits in the available memory. Suddenly the game designer decides that the game should also be able to scroll from left to right at any point, and for any duration. Stunned and dismayed, you explain to him that RLE compression only works in one direction, but he’s adamant. Figure out a way of doing what he wants without using much (no more that 1K of) extra memory. Explain the algorithm used for decompressing in both directions. (assume the RLE algorithm used is: a positive byte N followed by a byte B, indicates a run of N copies of B, a negative byte -N followed by N bytes indicates that those bytes should be copied directly. For example, the sequence 2,2,2,2,5,1,2,9,9,9,9,9 would be coded 4,2, -3,5,1,2, 5,9.)
how can I compress the information? My first thought was making a change to the RLE compression but i gave up on that thinking it wasn't possible.
View 2 Replies
View Related