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) {
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.
Point p1(100,100); Point p2(300,200); Graph_lib::Rectangle r(p1,p2);
And also I have a function that takes a rectangle and returns a Point of that, say, top-left corner of that rectangle. For example:
Point N(Graph_lib::Rectangle R1);
My question is that, first, how to send that Rectangle r(p1,p2) to the Point N(Graph_lib::Rectangle R1) function? And then, how to return a Point from that function?
I'm in the beginning stages of designing my first video game using SDL, and have run into a bit of an impasse. I attempt to draw the map using a simple tile function and nothing prints to the screen. I am going to attach the function itself.
bool Tile::draw_tiles ( void ) { GV gv;
//Open the map std::ifstream map ( "test.map" ); for ( int y = 0; y < GV::MAP_HEIGHT / 64; y++ ) { for ( int x = 0; x < GV::MAP_WIDTH / 64; x++ ) {
[Code] ....
Extra notes: 1. Compiles fine. 2. No run time errors (this function returns true). 3. Apply surface is a function that takes an x and y value for position on the map, an image, a screen to print it to, and a rectangle to cut out the image out of. 4. I did some bug testing and added another function to print the image SDLS_tiles by itself (its just a simple sprite map) after the map.close() function, and it worked fine.
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:
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.
i have to make an application called " paint " in c++ . It should facilitate user to draw different shapes using a mouse. Now the biggest hurdle i am facing is the usage of mouse .. what is the header file for usage of mouse ? i am using visual studio 2010 . the syntax is creating problems ..
Found a good beginner's tutorial to learn Visual C++: [URL] ....
How to change the drawing so that instead of squares, the game draws circles. Can figure out that using Ellipse in the code results in circle outlines, but the fill remains as square color shapes.
The drawing code from the tutorial is below. How to substitute filled circles for filled squares.
Code:
// CSameGameView drawing void CSameGameView::OnDraw(CDC* pDC){ // First get a pointer to the document CSameGameDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if(!pDoc)
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.
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
I'm doing a project and I need to draw a square into a pgm image if certain conditions are met, but I'm not sure how to draw the square into the image.
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.
For my code, I am getting a value for lengths of x, y and z like "getXlength(x_length)" etc... I would like to know how I can use these values to draw the prism rather than giving values for each coordinates in each face.
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;
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.
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:
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...
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
1) Write a program that asks the user for a a single character and two XY coordinates. The two X and two Y values should all be integers between 0 and 50. The character should be a printable ASCII character with values between and including ' !' (ascii value 33) and '~' (ascii value 126).
2) Your program should then draw a rectangle made up of the user selected character where the upper left corner is at X1; Y 1 and the lower right corner is at X2; Y2. Be sure to print the appropriate number of blank lines (having spaces in the blank rows is OK) in the beginning and pad each row of your rectangle with X1 leading spaces.
The Output is supposed to be similar to this:
(X1,Y1) = (0,0) , (X2,Y2) = (4,4), the character = ^
^^^^ ^^^^ ^^^^ ^^^^
What I am having trouble understanding is printing between certain ASCII values (ASCII has never been discussed in class).
Another thing I am having trouble with is the main part of the assignment. From what we are currently discussing is loops and the assignment is covering nested loops. My code looks similar to this: Code:
#include <stdio.h> int main (void) { int X1, Y1, X2, Y2; char cRec; printf("Enter a character: "); scanf("%c", &cRec);
[Code] .....
My thinking on the assignment is that you want the X1 coordinate to increase to the value of X2 (same for Y1 and Y2). Is this thinking wrong?
Make an "analog clock" that is, a clock with hands that move. You get the time of day from the operating system through a library call. A major part of this exercise is to find the functions that give you the time of day and a way of waiting for a short period of time (e.g., a second for a clock tick) and to learn to use them based on the documentation you found. Hint: clock(), sleep().
OK, I wrote below code. It is in its primary stages and has not been completed yet.
#include <GUI.h> #include <time.h> #include <iostream> using namespace Graph_lib;
[Code] .....
I expect the system in void clock_hands() (line 38) attaches hour1 (line 41) then waits for 1000 ms (using Sleep(1000)) then detaches hour1 and attaches hour2 this time. But it doesn't occur in practice. When the system reaches Sleep(1000); it seems to go into a comma! It doesn't show the hour1 so seeing the movement of clock ticks by the clock's hands will not be possible.