C++ :: Create BMP File (Grayscale)
Feb 11, 2014I now have a file with X, Y, Z and Intensity (0-1) of all the pixels. I want to create a .bmp file (grayscale) with this information in C++. How to do it?
View 1 RepliesI now have a file with X, Y, Z and Intensity (0-1) of all the pixels. I want to create a .bmp file (grayscale) with this information in C++. How to do it?
View 1 RepliesI'm trying to change a memory block values that is a 2d image. How to change to change scale but it's not working. This is the code
Vivienne
void Image::GenerateGrayScale(void) {
// create temporary area
unsigned char * tempdata_ = new unsigned char[width_ * height_ * depth_*components_];
unsigned char grey;
[Code] ....
I'm trying to employ this method [URL] .....
Problem in converting Jpeg to DIB, Iam using the same code for Jpeg RGB(Jpeg_color_space=JCS_RGB) and Grayscale Images(JCS_GRAYSCALE). this code works correctly for Jpeg RGB Images when i create DIB for 24 bit. But for Jpeg Grayscale(JCS_GRAYSCALE) images, when i am converting to DIB I get a Black color space next to image,but the original image does'nt contain any black space.
Following is the code i use for converting jpeg to DIB.
//Function to convert jpeg to dib.
int convert_jpeg_to_dib(const char * filename) {
struct jpeg_decompress_struct cinfo;
unsigned char * buffer;
int result = 0;
struct my_error_mgr jerr;
FILE * infile; /* source file */
int row_stride; /* physical row width in output buffer */
[Code] .....
I have an assignment on image processing and amongst other question one of them specifies:calculate the equalized histogram of a grayscale image and show statistical data of your choice between the input and output images.
I am having trouble equalizing the histogram. Either I am missing the whole picture or minor details that cause problems.
Code:
// original histogram
for (i=0; i<lines; i++)
for (j=0; j<columns; j++)
hist[image_in[i][j]]++;
//histogram max and min
int hmax=-1,hmin=257;
for(int i=0;i<256;i++) {
[Code]...
I am thinking that my equalization formula is wrong, i might have incorrectly translated the mathematical formula from wikipedia to C code but i cant figure out why.
I have a bw(grayscale) image and want to calculate the slope for each pixel which returns a value 0 to 255 value.
Pixels are always between 0 and 255. The highest possible difference is 255. The end result would be 0 for no slope and 256 for the highest slope.
Would this formula work?
slopex = pixel[x+1,y] - pixel[x - 1,y];
slopey = pixel[x,y+1] - pixel[x,y - 1];
totalslope = sqrt(slopex * slopex + slopey * slopey)*256;
I need to create a project that create a automated backup of a file.
i will get the file from C:/Folder/file.exe and move for a other created folder, but.. in every time that user make this backup, a folder will be created with year, month and date, like: C/Folder2/2014/April/16:42/file.exe.
The Objective Of This Program Is To Create A File To Write Text And Read Back The File Content. To Do That I Have Made Two Function writeFile() To Write And readFile() To Read.The readFile() function works just fine but writeFile() doesn't.
How writeFile() function Works? when writeFile() function Execute It Takes Characters User Type And When Hit Enter(ASC|| 10) It Ask "More?(Y/N)" That Means What User Want? Want To Go Next Line Or End Input?
If "Y" Than Inputs Are Taken From Next Line Else Input Ends.
But The Problem Is When Program Encounters ch==10 It Shows "More?(Y/N)" And Takes Input In cmd variable.If cmd=='Y' I Mean More From Next Line Than It Should Execute Scanf Again To Take ch I Mean User Input.But Its Not!!! Its Always Showing "More?(Y/N)" Again And Again Like A Loop.
Code:
#include <stdio.h>
void writeFile(void);
void readFile(void);
int main(){
[Code].....
I am interested in creating a file of a given size and then randomly accessing the file to populate it. Is there a way to quickly create, for instance, a 4 GByte file in C++, initially populated with garbage?
View 4 Replies View RelatedI have a folder "pics" in g: drive. There I want to create some text.txt file. Thus, the final path is "g:pics ext.txt".
How can I do that?
How do you create a save file for a game, that is not a separate file? Specifically I am using code::blocks and sfml 2.1 to make a game and it saves to a text file at the moment. My problem is that it is very easy to modify the text file, and it is annoying to have to copy and paste several files if you want to use a copy of the game. I have a feeling that it may be to do with resource files, but I'm not exactly sure how to get these to work or whether you can modify them dynamically.
View 6 Replies View RelatedI think this code should create a test.txt file but I cannot find it ?
Code:
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ofstream ofs;
ofs.open ("test.txt");
ofs.close();
return 0;
}
I want to create a program that would take an AVI file, alter each frame (ex: change contrast, invert colors, etc.) and dump a new AVI. I've wrote a simple program for this experiment that loads up the header information from the video and dumps it. It also dumps a list of the frame data chunks within the 'movi' chunk.
The info I've gathered from coding this:
1. The recommended buffer size for each type of stream (vids, auds, etc.) is the size of the largest frame of corresponding type, plus 1 or two extra bytes.
2. numFrames in main header is the total number of frames for all types of data (video,audio,etc.) The 'length' value within stream header of type 'vids' is the number of video frames. The sizeImage value within BITMAPINFOHEADER is 921600 (==640*480*3) and the specification states that, quoth, "This can be set to 0 for uncompressed RGB bitmaps."
3. This video uses DIVX encoding.
Now my problem is this: How do I get the data within each video frame in a simple BMP like format? Even the uncompressed frames (with chunk id 'nndb') have variable sizes...let alone the compressed ones.
Information about a software that converts AVIs to a format with fixed sized uncompressed frames. Or at least some information about the frame decompression techniques.
Here's a dump made by the program for a 9 sec, 640x480 video I recorded from Pokemon. (Without the frame dump that is, it'd have made the post too long.)
Code:
AviMainHeader
-------------
size = 56
usecPerFrame = 66666
maxBytesPerSec = 7680000
padSize = 0
flags = 0x00000810
numFrames = 162
initialFrames = 0
numStreams = 2
[Code]...
How do i create a data file?
View 2 Replies View RelatedAny good/solid example on how to create a header file?
View 2 Replies View RelatedIm having problems with this little function im making
for some reason the texture dont get created (messagebox never gets called)
Im trying to pass a BYTE array of a image to the function
void AddTexture(BYTE* texture)
{
LPDIRECT3DTEXTURE9 Direct3DTexture = NULL;
if (D3D_OK == D3DXCreateTextureFromFileInMemory(pDevice, &texture, sizeof(texture), &Direct3DTexture))
{
MessageBoxA(NULL, "created", "created", MB_OK);
}
}
For some unknown reason when i try the following code it doesn't create a file. (the program will simply get two inputs from the user and then use http to obtain the html/php text and then output it to a file)
code:
#include <SFML/Network.hpp>
#include <iostream>
using std::cout;
[Code].....
My problem is that I have to modify only some specific details in a txt file (actually it is a wrl file but it can be considered as a txt file). There is a lot of text there but I just need to modify the point coordinates and leave the rest of the text as it is. Reading the "sample file" at some stage we will see some blocks that look like the below:
coord Coordinate {
point [
# bottom
-1.0 -1.0 1.0, #vertex 0
1.0 -1.0 1.0, #vertex 1
[Code] ....
where the numbers are (X,Y,Z) coordinates. What I have to do is to change those figures for (X,0,sqrt(X^2+Z^2)) points. Therefore the expected result (test file) will be as follows:
coord Coordinate {
point [
# bottom
-1.0 0.0 1.4142, #vertex 0
1.0 0.0 1.4142, #vertex 1
[Code] .....
So in my opinion it can be good to have two files: sample.txt and test.txt where the sample file will never be modified whereas the test.txt will be the same as sample.txt but including the modifications as explained above. The idea can be to read the sample.txt, store the info and then start copying each line in the test file until we get to the points coordinates (which needs to be modified) and continuying with this process until the next set of coordinates.
The problem is that I do not know how to change x,y,z coordinates from the sample.txt to (X,0,sqrt(X^2+Z^2)) and to copy them in the test.txt. Please see some code below and the sample.txt file attached.
//Read a Text File///////////////////////////////////////////////////////////////////////////////////////////////////
using System;
using System.IO;
namespace readwriteapp {
class Class1
[code]....
I'm trying to create a Makefile for a single fie ( mycod.c)
What is the syntax?
I want to create three files whose names are same but extensions are different. I have to take the name from user. I tried following code but it didn't worked ...
Code:
printf("Name of the file:"); scanf("%s",name);
printf("Format of Input file:");
scanf("%s",ext);
f1=fopen(name.ext,"r");
f2=fopen(name.dat,"w");
f3=fopen(name.src,"w");
f4=fopen(name.RMH,"w");
I am trying to create an array with the size of the first value of one file wich is the same of the first line because the first line only have one value. Here is how i am trying to do it ...
FILE * fich;
int test;
fich=fopen(nome_ficheiro,"r");
fscanf_s(fich,"%d",&test);
int np=test;
No*aux=primeiro;
[Code] .....
When I write the Ctor as follows, I get an Error: Invalid Sharing Flag 0 (That happens when file exists or does not exist)
File::File(const string& file)
{
m_file.open(file, std::ios::out, std::ios::app);
}
When I write the Ctor as foolows, I manage to open / create a file.
File::File(const string& file)
{
m_file.open(file);
}
What is wrong with option #1?
note that m_file is a data member of type ofstream
I have created a desktop application using c#.net in visual studio 2005 and sql server 2005, i have created a setup file also but i dont have database in it.. how to include or attach the database file into the project so that it works well in the client machine.....
View 1 Replies View Relatedi am writing a program in Microsoft Visual C++ Express. The goal is to create a Autocad script file with this program. The extension of the script file is .scr
Now I first want to create the script file, then edit is and after that save it at a specific location. I want to activate this proces with a button. I have tried many tutorials about creating files but none have worked yet. My questions are:
- How do I create the script file?
- How do I edit it?
-How do I save it?
- Where to put which code?
// PDFScripper.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
#include <Windows.h>
#include <stdio.h>
#include <tchar.h>
#include <WinBase.h>
[code].....
I have an assignment where I have to create an image and output it as a .ppm file. It has to have a black background and have some letters in a different color. My professor told me that my .ppm header should have p3 600 300 255 and P6 600 300 255(what this means, think it sets up the width x height which should be 300 x 600).
This is what I have so far:
#include <iostream>
#include <fstream>
using namespace std;
int main() {
struct pixel {
unsigned char red;
[Code] ....
Problem in first for loop and what it should look like inside of the for loop, after that I should be able to figure this out... with the fstream (how to output the results in a .ppm file).
I have a table in my database that has a 3 fields.
RuleID | RuleName | Rule
the ruleID is a randomly generated string of characters, RuleName is the name the user gives to the rule, and the Rule field is about 600 characters long and is just XML text.
I want to read that Rule field from the database and use it inside the function below.
private static List<MenuItem> LoadRules(bool evaluationType)
{
//string path = HttpContext.Current.Server.MapPath(string.Format("/Rules/{0}/{1}/", ip, evaluationType ? "Evaluation" : "Execution"));
[Code]...
This function loads an xml file from a static location and parses out some information to a context menu.
BUt i'm culeless on how to have the function read the xml info found inside my database.
I am currently having issues with the following code when trying to create a excel file using C#. This is the code that I have at the moment.
oXL = new Microsoft.Office.Interop.Excel.Application();
oXL.Visible = false;
oWK = (Microsoft.Office.Interop.Excel._Workbook)(oXL.Workbooks.Add(System.Reflection.Missing.Value));
oWK.SaveAs(path + "" + fileName);
oWS = (Microsoft.Office.Interop.Excel._Worksheet)oWK.Worksheets.get_Item(1);
oWS.Cells[1, 1] = "Student ID";
oWS.Cells[1, 2] = "Student Name";
oWK.Save();
The line that I am having issues with is
oWS = (Microsoft.Office.Interop.Excel._Worksheet)oWK.Worksheets.get_Item(1);
If I remove it, I am able to create and save teh workbook in the directory. However, I want to make some changes on a worksheet, and that is where the issue is. I have also tried using the line of code:
oWS = (Microsoft.Office.Interop.Excel._Worksheet)oWK.Worksheets[1];
This line had no luck either. The issue I am having is the error regarding InvalidOperationException: Dynamic operations can only be performed in homogenous AppDomain.