|
Hi everyone, I have a HBITMAP with alpha channel information. The alpha channel should already be premultiplied.
Nevertheless, when using GDI's AlphaBlend(..) function, the bitmap seems to have "black borders", means the semi-transparent areas are simply black.
Does this mean I am doing something wrong? Or is AlphaBlend that limited?
I guess I should avoid legacy GDI AlphaBlend, maybe some has a clue what alternatives I'd have for a dialog based application?
Is there something better in GDI+ for bitmaps with transparency? I am not really convinced to go for D2D for this bitmap only.
Cheers, Don Rolando
|
|
|
|
|
I think GDI+ will be better for bitmap to transplant
|
|
|
|
|
I'm developing on OS X 10.8.3. The following code is simple. It can perform two operations. If the read function is uncommented then the program will open the file at "address" and transfer all of its contents into data. If instead, the memcpy function is uncommented the program will copy the mmapped contents into data. I am developing on a mac which caches commonly used files in inactive memory of RAM for faster future access. I have turned off caching in both the file control and mmap becuase I am working with large files of 1 GB or greater. If i did not setup the NOCACHE option, the entire 1 GB would be stored in inactive memory.
If the read function is uncommented, the program behaves as expected. Nothing is cached and everytime the program is ran it takes about 20 seconds to read the entire 1 GB.
But if instead the memcpy function is uncommented something changes. Still i see no increase in memory and it still takes 20 seconds to copy on the first run. But every execution after the previous one, copies in under a second. This is very analogous to the behavior of caching the entire file in inactive memory, but I never see an increase in memory. Even if I then do not mmap the file and only perform a read, it performs in the same time, under a second.
Something must be getting stored in inactive memory, but what and how do I track it? I would like to find what is being stored and use it to my advantage.
I am using activity monitor to see a general memory size. I am using Xcode Instruments to compare the initial memcpy execution to an execution where both read and memcpy are commented. I see no difference in the Allocations, File Activity, Reads/Writes, VM Tracker, or Shared Memory tools.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/mman.h>
int main(int argc, const char * argv[])
{
unsigned char *data;
unsigned char *mmapdata;
size_t length;
int file = open("address", O_RDONLY);
fcntl(file, F_NOCACHE, 1);
struct stat st;
stat("address", &st);
length = st.st_size;
data = malloc(length);
memset(data,0,length);
mmapdata = mmap(NULL, length, PROT_READ,MAP_SHARED|MAP_NOCACHE, file, 0);
if (mmapdata == MAP_FAILED)
fprintf(stderr, "failure");
// read(file,data,length);
close(file);
// memcpy(data,mmapdata,length);
munmap(mmapdata,length);
free(data);
return 0;
}
|
|
|
|
|
This seems more a question for a MacOS, rather than a C++ coding, forum.
Use the best guess
|
|
|
|
|
Is there a mac/OS X forum here? I couldn't find one and since this is in C i posted it here.
|
|
|
|
|
Member 9993401 wrote: Is there a mac/OS X forum here? No, this site is predominantly Windows focused.
Use the best guess
|
|
|
|
|
I have hWnd of main window of other process and I need to increase priority of this thread or process. How to do it?
|
|
|
|
|
|
I need a counter in C++ to my windows form.
Code:
int counter60
counter60 ++;
Counter->Text = System::Convert::ToString(counter60);
I only counts to 1, first time i klik the button. I have it under my Button click.
What is wrong here ?
|
|
|
|
|
At a guess, since you did not provide the relevant code, you are initializing counter60 to 0 every time on your button click and incrementing it to 1.
And this is C++/CLI and should have been posted in the appropriate forum.
|
|
|
|
|
You need to put your counter variable in the class; or make it a static variable.
Now, I assume you re-create the variable each time you click on the button.
(in c++, pseudo-ish code....)
class YourClass
{
YourClass();
int m_Counter;
void OnButtonClick();
}
YourClass::YourClass () : m_Counter(0)
{
}
void YourClass::OnButtonClick()
{
m_Counter++;
Counter->Text = System::Convert::ToString(counter60);
}
Nihil obstat
|
|
|
|
|
How do you mean "Re-create" ?
I am kind of a rookie.
I use Visual c++ 2010.
|
|
|
|
|
Do you have to call an updatedata() type func like in MFC to refresh the GUI?
If not debug it, it shoud be 61 not 1. Step into the converttostring and make sure you get the right string back, then step into the ->Text func and make sure its being set.
==============================
Nothing to say.
|
|
|
|
|
> This < should help.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
Hi,
I have created a property sheet. On that 3 Tab controls and three pages have been added.
When I use new larger Images for Tab controls, then it didn't display full Image, it accepts the older size of the Image and display new Image in that area only.
How to resize tab controls in mfc.
Any help will be appreciated.
Regards,
Mbatra
modified 16-Apr-13 7:48am.
|
|
|
|
|
|
I am not sure what you really want but u can use
MoveWindow()
Function .
Moves,resize window as per co-ordinate. 
|
|
|
|
|
do you know how to assign strings in c program?please answer me.
|
|
|
|
|
Yes I do know. Now, what is your question?
Use the best guess
|
|
|
|
|
"assign strings in C"
A Question for you. Does C language support Object Oriented Concepts?
|
|
|
|
|
Objective-C does.
Standard C, no.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
|
No sign of ++ in the OP heading. That's why I didn't mention it.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
const char* string = "string";
If you want a string that is not constant, that would be assigned differently, and the answer would depend on whether you mean "assign memory space" or "assign the characters forming the string" when you say "assign", as these are two separate activities in C.
What do you want to know? What have you tried? What books and/or articles have you read, and what is it you do not understand? Who was that masked stranger?
|
|
|
|
|
Here is wide character string version for international users.
const wchar_t* string = "string";
Unicode/MBCS gets very messy developing on Windows, dependent on whether UNICODE is defined at compile time.
see this article for a comprehensive explanation.
What-are-TCHAR-WCHAR-LPSTR-LPWSTR-LPCTSTR-etc?
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|