Question: program in C + + with inline assembly ( needs to be . cpp source code with embedded assembly ) The problem: please use my

program in C++ with inline assembly (needs to be .cpp source code with embedded assembly)
The problem:
please use my bit map creation program as reference:
#include
#include
#include
using namespace std;
#define IMAGE_SIZE 256
void drawLine(int x0, int y0, int x1, int y1, char bits[IMAGE_SIZE][IMAGE_SIZE]);
int main(){
// Initializes the bitmap array
char bits[IMAGE_SIZE][IMAGE_SIZE];
for (int i =0; i < IMAGE_SIZE; ++i){
for (int j =0; j < IMAGE_SIZE; ++j){
bits[i][j]=255- static_cast((255.0/ IMAGE_SIZE)* i);
}
}
// User input
cout << "Enter two pairs of point coordinates in the range of 0-"<< IMAGE_SIZE -1<<":"<< endl;
int x0, y0, x1, y1;
cin >> x0>> y0>> x1>> y1;
// Checks if input values are within range
if (x0<0|| x0>= IMAGE_SIZE || y0<0|| y0>= IMAGE_SIZE ||
x1<0|| x1>= IMAGE_SIZE || y1<0|| y1>= IMAGE_SIZE){
cout << "Value out of range, ending." << endl;
return -1;
}
drawLine(x0, y0, x1, y1, bits);
ofstream bmpOut("output.bmp", ios::out | ios::binary);
if (!bmpOut){
cout << "Could not open file, ending." << endl;
return -1;
}
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER bmih;
RGBQUAD colors[256];
bmfh.bfType =0x4d42;
bmfh.bfReserved1=0;
bmfh.bfReserved2=0;
bmfh.bfOffBits = sizeof(bmfh)+ sizeof(bmih)+ sizeof(colors);
bmfh.bfSize = bmfh.bfOffBits + IMAGE_SIZE * IMAGE_SIZE; // Actual size of the bitmap data
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biWidth = IMAGE_SIZE;
bmih.biHeight = IMAGE_SIZE;
bmih.biPlanes =1;
bmih.biBitCount =8; //8-bit grayscale
bmih.biCompression = BI_RGB;
bmih.biSizeImage =0;
bmih.biXPelsPerMeter =2835; // Standard resolution
bmih.biYPelsPerMeter =2835;
bmih.biClrUsed =0; //0 colors used
bmih.biClrImportant =0;
//Sets Bitmap with a grayscale background
for (int i =0; i <256; ++i){
colors[i].rgbBlue = colors[i].rgbGreen = colors[i].rgbRed = i;
colors[i].rgbReserved =0;
}
// Write headers to the file
bmpOut.write(reinterpret_cast(&bmfh), sizeof(bmfh));
bmpOut.write(reinterpret_cast(&bmih), sizeof(bmih));
bmpOut.write(reinterpret_cast(colors), sizeof(colors));
// Write bitmap data
bmpOut.write(reinterpret_cast(bits), IMAGE_SIZE * IMAGE_SIZE);
bmpOut.close();
// Opens bitmap in Windows Paint
system("mspaint output.bmp");
return 0;
}
// Draws line
void drawLine(int x0, int y0, int x1, int y1, char bits[IMAGE_SIZE][IMAGE_SIZE]){
int dx = abs(x1- x0);
int dy = abs(y1- y0);
int sx = x0< x1?1 : -1;
int sy = y0< y1?1 : -1;
int err = dx - dy;
while (true){
// Calculate brightness based on distance from the start point
float brightness =255.0f *((float)(dx - abs(x0- x1))/ dx);
bits[y0][x0]= static_cast(brightness); // Set pixel to grayscale value
// Increase line width by 2 pixels
for (int i =1; i <=2; ++i){
if (y0+ i < IMAGE_SIZE){
bits[y0+ i][x0]= static_cast(brightness);
}
if (y0- i >=0){
bits[y0- i][x0]= static_cast(brightness);
}
}
if (x0== x1 && y0== y1) break;
int e2=2* err;
if (e2>-dy){ err -= dy; x0+= sx; }
if (e2< dx){ err += dx; y0+= sy; }
}
}
---------
use this program to to draw lines in a bit map which provide a geographic map outline. Please adjust code so that the line calculating part is in inline assembly
--------
After creating the basic bit map (1024 by 1024 pixels), your program will read a text file which contains pairs of longitude and latitude numbers (in that order). These values will be positive, and will be within the following dimensions:
North - maximum latitude =38.995110
West - maximum longitude =-77.119900
South - minimum latitude =38.791513
East - minimum longitude =-76.909395
(For longitude, maximum and minimum are relative to their absolute value.)
---- here is the text file: DCBoundaryFile.txt
District of Columbia
-77.03859838.791513
-77.03889838.800813
-77.03579838.814913
-77.03809838.815613
-77.03909838.821413
-77.03809838.828612
-77.03919938.832212
-77.04119938.833712
-77.04259938.833812
-77.04349938.833212
-77.04489938.834712
-77.04499938.838512
-77.04419938.840212
-77.04169938.840212
-77.03279838.841712
-77.03169838.850512
-77.03929938.864312
-77.03889938

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!