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
ADVERTISEMENT
Dec 31, 2013
I dumped all symbols into C:WindowsSymbols folder, It takes more than 2 minutes to load an application which really surprises me. Why and when should I use those symbols?
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
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
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
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
Apr 1, 2014
Is there a good way to slow down program output? usleep and nanosleep don't slow it down enough, delay doesn't work, and sleep keeps freezing my program. I am using Linux since I think this makes a difference in what I have to use.
View 9 Replies
View Related
Aug 27, 2013
I am writing a program, the trouble is is that it uses a single thread and is SLOW.
View 10 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
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
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
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
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
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
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
Jun 24, 2014
C# Code
[DllImport("dllTestForm.dll", EntryPoint = "showFormC")]
static extern void testShowFormC(byte[] photo,int len);
private void button6_Click(object sender, EventArgs e) {
Bitmap bmp = (Bitmap)Image.FromFile(@"d:11.jpg");
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
[Code] ....
The program has no tip errors ,But there is no any picture display in c++ form,Tested the simple data types, such as int, can be normal .
View 1 Replies
View Related
Aug 6, 2014
I need to calculate the average brightness of a defined area in a bitmap. Is there a way to select the area which a watermark is going to be applied to, and then find it's average brightness?
I have the below code, but at the moment Color pixel is displaying 0, 0, 0 for RGB, I believe i'm doing it wrong, I have tried to use this as a reference but use part of the image instead of the entire image.
See Company Watermark region!
public void addWatermark() {
Image source = Image.FromFile("C:UsersMartyn BallDesktopImages 38.JPG");
Image watermark1 = Image.FromFile(Glb_venueWatermark);
Image watermark2 = Image.FromFile(Glb_companyWatermark);
//Get width and height of image
int sourceWidth = source.Width; int sourceHeight = source.Height;
[code]....
View 11 Replies
View Related
Nov 3, 2014
I've been given the task of converting a java application to a c# windows form application. The program displays a Mandelbrot which then allows the user to zoom into. I've managed to display the Mandelbrot and even zoom. However when dragging a box to zoom, the box its self doesn't show, meaning the user cannot see what area they will be zooming into.
I believe I need to call the update function which draws the rectangle as I drag however no matter what I try, I get errors from a red cross instead of the Mandelbrot to compile errors. Here is the code that I believe is relevant.
public void update(Graphics g) {
Color color = Color.White;
Pen myPen = new Pen(color);
g.DrawImage(myBitmap, 0, 0);
if (rectangle) {
[Code]....
View 3 Replies
View Related
Mar 9, 2014
I wanna write a piece of code in C++ that extract the width and height of a image with bmp file format...
View 2 Replies
View Related
Nov 2, 2014
creating a bitmap. Our professor wants us to creat a black 100*100 bitmap.
Code:
#include <stdio.h>
#include <stdlib.h>
#pragma pack(push,2)
typedef struct{
[Code].....
I dont even know where to start. I spend the last 7h infront of my computer and i'm so frustrated cause my professor gave us no information what so ever. At the moment its more of a trial and error process than anything else.
How would i set the color of an individual pixel for examplel or how would i save the file ?
View 1 Replies
View Related
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