Jump to content
  • Advertisement
Sign in to follow this  

OpenGL convert tiff to raw

This topic is 3477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i try to change my code into opengl code. but it have error.. so sad.. who can help me??? please save me.. sir. what problem went i put my code into lesson34 it not display the terrain. my code is about read tiff image then convert it to raw image. that is my code. #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <iostream.h> #include <fstream.h> #include <math.h> #include <string.h> #define ROW 1000 #define COLUMN 1000 short unsigned int rawData[ROW][COLUMN]; struct HEADER { short int ByteOrder; short int version; long int OffsetOfFirstIFD; short int noOfDE; }; struct DE { short int tag; short int type; long int length; long int value; }; struct IMAGE { long int width; long int length; long int dataBegin; long int dataSize; }; void readTiff (LPSTR& , HEADER& , DE* , IMAGE&); void main() { LPSTR fileTiff; IMAGE img; HEADER head; DE de; fileTiff.open ("1983-2.tif", ios::in | ios::binary); if (!fileTiff) { cout<<" \n\tFile cannot be read... "<<endl; } readTiff(fileTiff, head, &de, img); fileTiff.close(); getch(); } void readTiff(LPSTR& fileTiff, HEADER& head, DE *de , IMAGE& img) { int i; ofstream raw; raw.open("1983-2.raw", ios::out|ios::binary); if(!raw) { cout<<"Failed!!"; } fileTiff.read((char*) &head.ByteOrder,2); fileTiff.read((char*) &head.version,2); fileTiff.read((char*) &head.OffsetOfFirstIFD,4); fileTiff.read((char*) &head.noOfDE,2); short int noOfDE = head.noOfDE; de = new DE[noOfDE]; for(i = 0; i < noOfDE; i++) { fileTiff.read((char*) &de.tag,2); fileTiff.read((char*) &de.type,2); fileTiff.read((char*) &de.length,4); fileTiff.read((char*) &de.value,4); if(de.tag == 256) //ImageWidth { img.width = de.value; cout<<img.width; } if(de.tag == 257) //ImageLength img.length = de.value if(de.tag == 273) //StripOffsets img.dataBegin = de.value; if(de.tag == 279) //StripByteCounts img.dataSize = de.value; i++; } fileTiff.seekg(img.dataBegin,ios::beg); for(i = 0; i<img.length; i++) { for(int j = 0; j<img.width; j++) { fileTiff.read((char*) &rawData[j],1); raw.setf(ios::hex); raw.write((char*) &rawData[j],sizeof rawData[j]); } } raw.close(); }

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!