Search Results

Search found 3117 results on 125 pages for 'buffer'.

Page 42/125 | < Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >

  • Best way to reverse bitmap data that is upside down

    - by Wladimir
    Hello, I have a method that I call and it returns bitmap data from a capture device. It returns a pointer to the buffer data as an IntPtr and the buffer length as an int. I know in advance that this bitmap is a 24bpp and its width and height. The problem is that the buffer contains the bitmap data upside down and I need this data to be in the right order (reverse it). What I do is create a for loop and using CopyMemory, I copy each line (stride) of this data from bottom to up to a newly allocated memory space. Is there any way to make it faster than creating more memory each time I receive a new frame? It makes the application get a bit slow and consumes more memory as each bitmap is pretty big. I do this because I use another component that analyses the bitmaps and it doesn't work propertly if the bitmaps are upside down. I'm using .net, c# thanks!

    Read the article

  • Autocorrelation method for pitch determination: what is the input data form?

    - by harsh
    I have read a code for pitch determination using autocorrelation method. Can anybody please tell what would be the input data (passed as argument to DetectPitch()) function here: double DetectPitch(short* data) { int sampleRate = 2048; //Create sine wave double *buffer = malloc(1024*sizeof(short)); double amplitude = 0.25 * 32768; //0.25 * max length of short double frequency = 726.0; for (int n = 0; n < 1024; n++) { buffer[n] = (short)(amplitude * sin((2 * 3.14159265 * n * frequency) / sampleRate)); } doHighPassFilter(data); printf("Pitch from sine wave: %f\n",detectPitchCalculation(buffer, 50.0, 1000.0, 1, 1)); printf("Pitch from mic: %f\n",detectPitchCalculation(data, 50.0, 1000.0, 1, 1)); return 0; }

    Read the article

  • problem with NSInputStream on real iPhone

    - by ThamThang
    Hi guys, I have a problem with NSInputStream. Here is my code: case NSStreamEventHasBytesAvailable: printf("BYTE AVAILABLE\n"); int len = 0; NSMutableData *data = [[NSMutableData alloc] init]; uint8_t buffer[32768]; if(stream == iStream) { printf("Receiving...\n"); len = [iStream read:buffer maxLength:32768]; [data appendBytes:buffer length:len]; } [iStream close]; I try to read small data and it works perfectly on simulator and real iPhone. If I try to read large data (more than 4kB or maybe 5kB), the real iPhone just can read 2736 bytes and stop. Why is it? Help me plz! Merci d'avance!

    Read the article

  • How to calculate the correct image size in out pdf using itextsharp ?

    - by MK
    I' am trying to add an image to a pdf using itextsharp, regardless of the image size it always appears to be mapped to a different greater size inside the pdf ? The image I add is 624x500 pixel (DPI:72): And here is a screen of the output pdf: And here is how I created the document: Document document = new Document(); System.IO.MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); document.Open(); System.Drawing.Image pngImage = System.Drawing.Image.FromFile("test.png"); Image pdfImage = Image.GetInstance(pngImage, System.Drawing.Imaging.ImageFormat.Png); document.Add(pdfImage); document.Close(); byte[] buffer = stream.GetBuffer(); FileStream fs = new FileStream("test.pdf", FileMode.Create); fs.Write(buffer, 0, buffer.Length); fs.Close(); Any idea why on how to calculate the correct size ?

    Read the article

  • Fseek on C problem

    - by Pedro
    i'm testing this code, but doesn't work, it always says that an error occurred :S int main(int argc, char **argv) { FILE *file_pointer; file_pointer = fopen("text.txt","r"); if(fseek(file_pointer, 0, -1)) { puts("An error occurred"); } else { char buffer[100]; fgets(buffer, 100, file_pointer); puts("The first line of the file is:"); puts(buffer); } fclose(file_pointer); return 0; }

    Read the article

  • snprintf and Visual Studio 2010

    - by Andrew
    I'm unfortunate enough to be stuck using VS 2010 for a project, and noticed the following code still doesn't build using the non-standards compliant compiler: #include <stdio.h> #include <stdlib.h> int main (void) { char buffer[512]; snprintf(buffer, sizeof(buffer), "SomeString"); return 0; } (fails compilation with the error: C3861: 'snprintf': identifier not found) I remember this being the case way back with VS 2005 and am shocked to see it still hasn't been fixed. Does any one know if Microsoft has any plans to move their standard C libraries into the year 2010?

    Read the article

  • Fatsest way to edit alpha of CGImage (or UIImage) with touch and then display?

    - by Pankaj
    I have two image views, one on top of the another, with two different images. As the user touches the image and moves his/her finger, the top image should become transparent along the touch points with a fixed radius. (Like the PhotoChop app). Currently I am doing it this way... For each touch. Get a copy of the image buffer from CGImage of the top image. Edit the alpha channel of the buffer to create a transparent circle centered at the touch point. Create new CGImage from the buffer. Create UIImage from the CGImage and use the new UIImage as the top image view's image. This works but as you can see too many copy, creates are involved and it is slow. Can somebody please suggest me a faster way of doing the same thing?

    Read the article

  • Autocorrelation method for pitch determination.. whats d input data form..?

    - by harsh
    i hav read a code for pitch determination using autocorrelation method. can anybody please tell wht wud b d input data(passed as argument to DetectPitch()) function here: double DetectPitch(short* data) { int sampleRate = 2048; //Create sine wave double *buffer = malloc(1024*sizeof(short)); double amplitude = 0.25 * 32768; //0.25 * max length of short double frequency = 726.0; for (int n = 0; n < 1024; n++) { buffer[n] = (short)(amplitude * sin((2 * 3.14159265 * n * frequency) / sampleRate)); } doHighPassFilter(data); printf("Pitch from sine wave: %f\n",detectPitchCalculation(buffer, 50.0, 1000.0, 1, 1)); printf("Pitch from mic: %f\n",detectPitchCalculation(data, 50.0, 1000.0, 1, 1)); return 0; }

    Read the article

  • Managing StringBuilder Resources in C#

    - by Jim Fell
    Hello. My C# (.NET 2.0) application has a StringBuilder variable with a capacity of 2.5MB. Obviously, I do not want to copy such a large buffer to a larger buffer space every time it fills. By that point, there is so much data in the buffer anyways, removing the older data is a viable option. Can anyone see any obvious problems with how I'm doing this (i.e. am I introducing more performance problems than I'm solving), or does it look okay? tText_c = new StringBuilder(2500000, 2500000); private void AppendToText(string text) { if (tText_c.Length * 100 / tText_c.Capacity > 95) { tText_c.Remove(0, tText_c.Length / 2); } tText_c.Append(text); } Thanks.

    Read the article

  • iPython in Emacs. Quick code evaluation

    - by AmV
    Hi all, I would like to "send" code snippets to a iPython interpreter in Emacs 23.2 (Linux). I have two related questions about this: Q1: I have learned that Emacs provides ('shell-command-on-region') to run selected regions in a shell. I have set setq shell-file-name to my iPython path, but when I run M-| after selecting a region, Emacs prompts me the following: Shell command on region: and if I then type RET, I get the iPython man page on the *Shell Command Output* buffer, without the region being executed. Why? Q2: Assuming that I have already started an iPython shell in some other buffer in Emacs, is there a way of selecting a region in another buffer and "sending" this region to the already-started iPython shell? Thanks!

    Read the article

  • status failed for LdrLoadDll

    - by kiddo
    hello all,I'am trying to work-out the LdrLoadDll function and am having no luck with that..i also googled for some examples there is no much documentation or correct example about this.I know what it exactly does..Please check the code below. //declaration function pointer for LdrLoadDll typedef NTSTATUS (_stdcall*fp_LdrLoadDll)( IN PWCHAR PathToFile OPTIONAL, IN ULONG Flags OPTIONAL, IN PUNICODE_STRING ModuleFileName, OUT PHANDLE ModuleHandle ); //calling LdrLoadDll using getprocaddress HANDLE handle; HMODULE module = LoadLibrary(L"ntdll.dll"); fp_LdrLoadDll loadDll; loadDll = (fp_LdrLoadDll)GetProcAddress(module,"LdrLoadDll"); if(loadDll == NULL) { MessageBox(0,L"Not able to load the function",L"LdrLoadDll",&handle); } UNICODE_STRING input; input.Buffer = L"C:\\Desktop\\myDll.dll"; input.Length = wcslen(input.Buffer)*2; input.MaximumLength = wcslen(input.Buffer) +2; NTSTATUS status = loadDll(NULL,LOAD_WITH_ALTERED_SEARCH_PATH,&input,0); When i execute the above am not getting the handle niether valid status.Please help me with this.

    Read the article

  • Will unused deconstructors be optimized out?

    - by Brendan Long
    Assuming MyClass uses the default deconstructor (or no deconstructor), and this code: MyClass buffer[] = new MyClass[i]; // Construct N objects using placement new for(size_t i = 0; i < N; i++){ ~buffer[i]; } delete[] buffer; Is there any optimizer that would be able to remove this loop? Also, is there any way for my code to detect if MyClass is using an empty/default constructor?

    Read the article

  • understanding memory mapping in directx

    - by numerical25
    So my question is ... " When your using the mapping feature to write into a memory buffer, are you really just saving the whole procedure into a queue so directX executes it when finished with other tasks???" I ask this question because this is my perception of mapping when writing to a buffer. I just want to make sure my perception is correct. I understand that the monitor moves extremely slow in compared to the processor, and I am sure the processor can execute 10 times the amount the screen can refresh. So is this one of the reason you should map when writing to a buffer. so each procedure can be done in a orderly fashion. If someone could elaborate, that would be great. thanks

    Read the article

  • Change English numbers to Persian and vice versa in MVC (httpmodule)?

    - by Mohammad
    I wanna change all English numbers to Persian for showing to users. and change them to English numbers again for giving all requests (Postbacks) e.g: we have something like this in view IRQ170, I wanna show IRQ??? to users and give IRQ170 from users. I know, I have to use Httpmodule, But I don't know how ? Could you please guide me? Edit : Let me describe more : I've written the following http module : using System; using System.Collections.Specialized; using System.Diagnostics; using System.IO; using System.Text; using System.Text.RegularExpressions; using System.Web; using System.Web.UI; using Smartiz.Common; namespace Smartiz.UI.Classes { public class PersianNumberModule : IHttpModule { private StreamWatcher _watcher; #region Implementation of IHttpModule /// <summary> /// Initializes a module and prepares it to handle requests. /// </summary> /// <param name="context">An <see cref="T:System.Web.HttpApplication"/> that provides access to the methods, properties, and events common to all application objects within an ASP.NET application </param> public void Init(HttpApplication context) { context.BeginRequest += ContextBeginRequest; context.EndRequest += ContextEndRequest; } /// <summary> /// Disposes of the resources (other than memory) used by the module that implements <see cref="T:System.Web.IHttpModule"/>. /// </summary> public void Dispose() { } #endregion private void ContextBeginRequest(object sender, EventArgs e) { HttpApplication context = sender as HttpApplication; if (context == null) return; _watcher = new StreamWatcher(context.Response.Filter); context.Response.Filter = _watcher; } private void ContextEndRequest(object sender, EventArgs e) { HttpApplication context = sender as HttpApplication; if (context == null) return; _watcher = new StreamWatcher(context.Response.Filter); context.Response.Filter = _watcher; } } public class StreamWatcher : Stream { private readonly Stream _stream; private readonly MemoryStream _memoryStream = new MemoryStream(); public StreamWatcher(Stream stream) { _stream = stream; } public override void Flush() { _stream.Flush(); } public override int Read(byte[] buffer, int offset, int count) { int bytesRead = _stream.Read(buffer, offset, count); string orgContent = Encoding.UTF8.GetString(buffer, offset, bytesRead); string newContent = orgContent.ToEnglishNumber(); int newByteCountLength = Encoding.UTF8.GetByteCount(newContent); Encoding.UTF8.GetBytes(newContent, 0, Encoding.UTF8.GetByteCount(newContent), buffer, 0); return newByteCountLength; } public override void Write(byte[] buffer, int offset, int count) { string strBuffer = Encoding.UTF8.GetString(buffer, offset, count); MatchCollection htmlAttributes = Regex.Matches(strBuffer, @"(\S+)=[""']?((?:.(?![""']?\s+(?:\S+)=|[>""']))+.)[""']?", RegexOptions.IgnoreCase | RegexOptions.Multiline); foreach (Match match in htmlAttributes) { strBuffer = strBuffer.Replace(match.Value, match.Value.ToEnglishNumber()); } MatchCollection scripts = Regex.Matches(strBuffer, "<script[^>]*>(.*?)</script>", RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace); foreach (Match match in scripts) { MatchCollection values = Regex.Matches(match.Value, @"([""'])(?:(?=(\\?))\2.)*?\1", RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace); foreach (Match stringValue in values) { strBuffer = strBuffer.Replace(stringValue.Value, stringValue.Value.ToEnglishNumber()); } } MatchCollection styles = Regex.Matches(strBuffer, "<style[^>]*>(.*?)</style>", RegexOptions.Singleline | RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace); foreach (Match match in styles) { strBuffer = strBuffer.Replace(match.Value, match.Value.ToEnglishNumber()); } byte[] data = Encoding.UTF8.GetBytes(strBuffer); _memoryStream.Write(data, offset, count); _stream.Write(data, offset, count); } public override string ToString() { return Encoding.UTF8.GetString(_memoryStream.ToArray()); } #region Rest of the overrides public override bool CanRead { get { throw new NotImplementedException(); } } public override bool CanSeek { get { throw new NotImplementedException(); } } public override bool CanWrite { get { throw new NotImplementedException(); } } public override long Seek(long offset, SeekOrigin origin) { throw new NotImplementedException(); } public override void SetLength(long value) { throw new NotImplementedException(); } public override long Length { get { throw new NotImplementedException(); } } public override long Position { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } #endregion } } It works well, but It converts all numbers in css and scripts files to Persian and it causes error.

    Read the article

  • How to move file pointer to a particular location using fseek()?

    - by Noge
    My intention is to read every elements in the 2nd column into a buffer[] from the following .txt file: 9992891234 09.920 15.771 11.909 9992345971 07.892 12.234 09.234 9992348971 64.567 70.456 50.987 9992348231 89.234 85.890 58.982 I have know of a way to do it by using fscanf(): for (int i=0;i<4;i++) { fscanf(pFile, "%lld", &junk); fscanf(pFile, "%f", &buffer[i]); fscanf(pFile, "%f", &junk); fscanf(pFile, "%f", &junk); } However, since I'm doing parallel programing which requires me to use different Windows Threads to read different columns, so I'll need to read the elements in the 2nd column directly using fseek(). The question here is, what should I put in the 2nd argument in fseek() in the code below to move my file pointer to read the 2nd element of the 2nd line? fscanf(pFile, "%llf", &junk);//<------this is used to skip the 1st data for (int i=0;i<4;i++) { fscanf(pFile, "%f", &buffer[i]); fseek ( pFile , ??, SEEK_CUR );//<----how do I calculate this offset? }

    Read the article

  • C# dll import function correctly

    - by poco
    I am trying to import a function from a c dll into C#. The c function looks like this unsigned short write_buffer( unsigned short device_number, unsigned short word_count, unsigned long buffer_link, unsigned short* buffer) my attempt at a C# import looks like this [DllImport("sslib32.dll", CharSet = CharSet.Ansi, SetLastError = true)] private static extern ushort write_buffer(ushort deviceNumber, ushort wordCount, UInt32 bufferLink, IntPtr buffer) In C# i have a Dictionary of messages that i would like to pass to this function. The Dictionary looks like this: Dictionary<string, List<ushort>> msgs I am a bit confused how to make a make a proper call to pass msgs as the buffer. deviceNumber is 2, wordCount is 32, and buffLink is 0. So i know the call should look something like this write_buffer(2,32,0, msgs[key]); Obviously i am getting an invalid argument for the IntPtr. What is the proper way to make this call?

    Read the article

  • Add progressbar to BZip2CompressorInputStream

    - by bordeux
    This is my code: public void extract(String input_f, String output_f){ int buffersize = 1024; FileInputStream in; try { in = new FileInputStream(input_f); FileOutputStream out = new FileOutputStream(output_f); BZip2CompressorInputStream bzIn = new BZip2CompressorInputStream(in); final byte[] buffer = new byte[buffersize]; int n = 0; while (-1 != (n = bzIn.read(buffer))) { out.write(buffer, 0, n); } out.close(); bzIn.close(); } catch (Exception e) { throw new Error(e.getMessage()); } } How can i add progress bar to extract task, or how can i get the compressed file size?

    Read the article

  • Why this function overloading is not working?

    - by Jack
    class CConfFile { public: CConfFile(const std::string &FileName); ~CConfFile(); ... std::string GetString(const std::string &Section, const std::string &Key); void GetString(const std::string &Section, const std::string &Key, char *Buffer, unsigned int BufferSize); ... } string CConfFile::GetString(const string &Section, const string &Key) { return GetKeyValue(Section, Key); } void GetString(const string &Section, const string &Key, char *Buffer, unsigned int BufferSize) { string Str = GetString(Section, Key); // *** ERROR *** strncpy(Buffer, Str.c_str(), Str.size()); } Why do I get an error too few arguments to function ‘void GetString(const std::string&, const std::string&, char*, unsigned int)' at the second function ? Thanks

    Read the article

  • reading unicode

    - by user121196
    I'm using java io to retrieve text from a server that might output character such as é. then output it using System.err, they turn out to be '?'. I am using UTF8 encoding. what's wrong? int len=0; char[]buffer=new char[1024]; OutputStream os = sock.getOutputStream(); InputStream is = sock.getInputStream(); os.write(query.getBytes("UTF8"));//iso8859_1")); Reader reader = new InputStreamReader(is, Charset.forName("UTF-8")); do{ len = reader.read(buffer); if (len0) { if(outstring==null)outstring=new StringBuffer(); outstring.append(buffer,0,len); } }while(len0); System.err.println(outstring);

    Read the article

  • Freeing a character pointer returns error

    - by Kraffs
    I'm trying to free a character pointer after having used it but it returns a strange error. The error says: "_CrtDbgREport: String too long or IO Error" The debugger itself returns no errors while compiling. The code currently looks like this: void RespondToUser(SOCKET client, SOCKET server) { char buffer[80]; char *temp = malloc(_scprintf("HTTP/1.1 200 OK\r\n%s\r\nServer: %s\r\nConnection: close\r\n\r\nHi!", buffer, SERVER_NAME)); sprintf(temp, "HTTP/1.1 200 OK\r\n%s\r\nServer: %s\r\nConnection: close\r\n\r\nHi!", buffer, SERVER_NAME); send(client, temp, strlen(temp), 0); closesocket(client); free(temp); ListenToUsers(server); } The problem only occurs when I try to free the temp pointer from the memory and not otherwise. What might be causing this?

    Read the article

  • Talking to a server in Win32; how do I see the server's response?

    - by Vinod K
    I am new to Win32 programming. sprintf(lpszBuff,"HELO Mail-Server\r\n"); send(s,lpszBuff,strlen(lpszBuff),0); recv(s,lpszBuff,100,0); cout << lpszBuff; In here I connect to a local mail server. The buffer contains the request I send, the same buffer contains the reply send by the browser. How do I see the reply? cout <<buffer doesn't show any output. I am doing this on VC++ 2008.

    Read the article

  • Array of datas returning issue, Overwriting

    - by sijith
    Hi, Please help me on this Here i want to save the converted data into new pointers. But everytime the data is overwriting with most recent data. Please check my code TCHAR nameBuffer[256]; //Globally Declared void Caller() { TCHAR* ptszSecondInFile= QStringToTCharBuffer(userName); TCHAR* ptszOutFile=QStringToTCharBuffer(Destinationfilename); } TCHAR *dllmerge::QStringToTCharBuffer( QString buffer ) { memset(nameBuffer, 0, sizeof(nameBuffer)); #if UNICODE _tcscpy_s(nameBuffer, _countof(nameBuffer), buffer.toUtf8()); #else _tcscpy_s(nameBuffer, _countof(nameBuffer), buffer.toLocal8Bit()); #endif _tprintf( _T( "nameBuffer %s\n" ), nameBuffer ); return nameBuffer; } I am gettting ptszSecondInFile and ptszOutFile both same answer. Is it possible to do with TCHAR* nameBuffer[256];

    Read the article

  • How to copy one Stream to a byte array with the smallest C# code?

    - by estourodepilha.com
    Until now I am counting 12 LoCs. Could you make it smaller? using (Stream fileStream = File.OpenRead(fileName)) { using (BinaryReader binaryReader = new BinaryReader(fileStream)) { using (MemoryStream memoryStream = new MemoryStream()) { byte[] buffer = new byte[256]; int count; int totalBytes = 0; while ((count = binaryReader.Read(buffer, 0, 256)) > 0) { memoryStream.Write(buffer, 0, count); totalBytes += count; } memoryStream.Position = 0; byte[] transparentPng = new byte[totalBytes]; memoryStream.Read(transparentPng, 0, totalBytes); } } }

    Read the article

  • Convert a number from string to integer without using inbuilt function

    - by Raja
    I am trying this technique but error is coming. Please help me to convert a number from string to integer. #include<iostream> using namespace std; int main() { char *buffer[80]; int a; cout<<"enter the number"; cin.get(buffer,79); char *ptr[80] = &buffer; while(*ptr!='\0') { a=(a*10)+(*ptr-48); } cout<<"the value"<<a; delete ptr[]; return 0; } Errors are: error C2440: 'initializing' : cannot convert from 'char ()[80]' to 'char *[80]' error C2440: '=' : cannot convert from 'char *' to 'int'

    Read the article

  • AudioTrack skipping after pause and resume

    - by Markus Drösser
    Hi, here is the problem. I play a wav file that i recorded earlier without problems. but when i call audiotrack.pause() and audiotrack.start() again after some waiting, it skips some frames of the file. why is that? here is my play listener // Start playback audioTrack.setPlaybackPositionUpdateListener(new OnPlaybackPositionUpdateListener() { @Override public void onPeriodicNotification(AudioTrack track) { try { if(ramfile!=null && ramfile.read(buffer)==-1) { audioTrack.release(); audioTrack = null; ramfile.close(); playing=false; } else { audioTrack.write(buffer, 0, buffer.length); } } catch (IOException e) { try { ramfile.close(); playing=false; } catch (IOException e1) { } } } @Override public void onMarkerReached(AudioTrack track) { playing=false; track.release(); } });

    Read the article

< Previous Page | 38 39 40 41 42 43 44 45 46 47 48 49  | Next Page >