C# :: Drawing Rectangle On Bitmap (Mandelbrot)
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
ADVERTISEMENT
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
Oct 23, 2013
write a code that draw a block and diamond each in a single run by using '*' in recursion.
Below are one 10X10 rectangle and 6X4 diamond.
**********
**********
**********
**********
**********
**********
**********
**********
**********
**********
**
* *
* *
* *
* *
* *
* *
* *
**
Note: I couldn't write the diamond here appropriately somehow.
View 1 Replies
View Related
Apr 24, 2015
For a Texas holdem' project I need to be able to draw out rectangles using ASCII codes and for loops. I started the code
#include <iostream>
#include <string>
#include <Windows.h>
[Code].....
View 6 Replies
View Related
Jan 23, 2015
I am trying to draw a rubber band rectangle. I have got a following code from a site but its giving an error:
Code:
class CSampleView: Public CView{
...
public:
CrectTracker m_tracker;//Changed to CRectTracker
...
};
Secondly, in the constructor to initialize the object CRectTracker document class:
CSampleDoc :: CSampleDOC () {
// Initialize tracker position, size and style.
m_tracker.m_rect.SetRect (0, 0, 10, 10);
m_tracker.m_nStyle = CRectTracker :: resizeInside |
CRectTracker :: dottedLine;
}
The error is:
error C2065: 'm_tracker' : undeclared identifier
How to get rid of this error??
View 4 Replies
View Related
May 13, 2014
Consider I have a rectangle like this:
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?
My IDE is visual studio 2012.
View 19 Replies
View Related
Jan 18, 2013
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.
View 1 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
May 3, 2013
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 ..
View 1 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
Mar 11, 2014
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)
[Code] ....
View 6 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
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
Nov 22, 2013
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.
View 2 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 10, 2013
I am supposed to create a class of rectangular prism in opengl. I am having touble in writing my "draw()" function.
I have searched the web, and lots of the sites have:
glBegin(GL_Quads);
glVertex3f(x,y,z);
glVertex3f(...);
glVertex3f(...);
glVertex3f(...);
3D coordinates for each face.
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.
View 1 Replies
View Related
Jan 27, 2014
This is the text of exercise 4 of chapter 12 of PPP; Draw a checkers board: 8-by-8 alternating white and red squares.
Is there a way to use the loop for doing that code to minimize the size of the code?
View 9 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
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
Sep 23, 2014
The assignment is:
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?
View 12 Replies
View Related
Jan 19, 2015
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.
View 5 Replies
View Related