|
|
|
You can simply use ImageAttributes::SetColorKey function.
ImageAttributes imageAttrs;
Color transparentClr(0, 0, 0);
imageAttrs.SetColorKey(transparentclr, transparentclr);
Use this image attributes in Graphics::DrawImage
graphics.DrawImage(&yourImage, yourRect, 0, 0, yourImage.GetWidth(), yourImage.GteHeight(),
Gdiplus::UnitPixel, &imageAttrs);
|
|
|
|
|
|
Hi all
I have one Window with size of 700*700.The view size is 500*500 and 100*100 of Opengl.
Now i am drawing some object on 500*500 opengl view.
how i can draw same object on 100 *100 view without create any new object?
means i want to use existing big view's object in Small view.
Let me know how can we archive this thing.
Thanks
|
|
|
|
|
We have the extra large icon view (256 x 256) since Windows Vista.
Now I have a control panel applet running under Win7 and Vista. I have added the icon resources with images of size 256 x 256 into the CPL. But the shortcut (on the Desktop) to this CPL applet does not display the icon correctly.
It is said that assigning the value CPL_DYNAMIC_RES for the idIcon member of CPLINFO structure in the CPL_INQUIRE message handler triggers Windows to send a CPL_NEWINQUIRE message. And then we assign the hIcon member of NEWCPLINFO in the CPL_NEWINQUIRE message handler for the icon information.
But no matter AfxGetApp()->LoadIcon or ::LoadImage (even with the LR_DEFAULTSIZE flag) fails to make the icon image of the shortcut on the Desktop display the correct sized image.
Does anyone know the correct way to handle the CPL_INQUIRE and CPL_NEWINQUIRE to make it display 256 x 256 image for the shortcut on the Desktop?
Thanks in advance.
Maxwell Chen
|
|
|
|
|
The root cause is in the ico file. Do not use PNG (do not compress) for the 256 x 256 and 128 x 128 frames. Use BMP (uncompressed) instead. And the issue is resolved.
Maxwell Chen
|
|
|
|
|
I have some structure like
struct abc{
int x;
char y;
DWORD z;
__int64 a;
char data[250];
}
I have this structure in some tree and i want to save tree contents in a file. Later i want read this file and fill the tree
is there any library available for that?
or is there any simple and fast way to do this
please sugget
|
|
|
|
|
In C you'd use fread and fwrite and in C++ you'd use std::istream::read and std::ostream::write to save plain old data (POD) structures without pointers to a file. All the functions I've mentioned read and write raw bytes so if you want a human readable file you'll have to use something else e.g. use formatted I/O in C and the stream insertion/extraction operators in C++.
Cheers,
Ash
modified on Monday, January 31, 2011 4:38 AM
|
|
|
|
|
simplest way are fwrite and fread.
WriteFile and ReadFile APIS are another options.
|
|
|
|
|
Hi,
I am drawing an image and moving it using mouse move. It is working fine. But If I load 2 MB image it is taking time to draw and also taking time to get refresh every time when I move the image.
How can I reduce the flicking?
|
|
|
|
|
instead of loading the image every time, load it first time, save in some memory dc or buffer. BitBilt this to your screen dc. You may use the whole drawings on another memory dc first, then copy it to window dc to avoid flickering.
see double buffering
|
|
|
|
|
Hi, I am using GDI+ function to darw image.
Graphics *g2 = new Graphics(pDc->GetSafeHdc());
g2->DrawImage(...);
How could I use double buffering concept here? Please give any example.
|
|
|
|
|
Bitmap membitmap(width, height, PixelFormat32bppPARGB);
Graphics memgraphics(&membitmap);
Graphics *g2 = new Graphics(pDc->GetSafeHdc());
g2->DrawImage(&membitmap);
An eg. here
Also, you can use CachedBitmap to optimize the rendering if you are loading and drawing same bitmap again and again.
|
|
|
|
|
Hi John,
You can solve your problem by implementing double buffering concept...ie you can do all the drawings in a bitmap and once your drawings are over just bitblt it in to your client DC..
Regards,
spk521
|
|
|
|
|
This is a very common problem with Windows GUI, and is appropriately named Flickering, and the solution to the problem is called Flicker Free Drawing.
There are 2 parts to fixing the problem:
1. You need to replace the WM_ERASEBKGND (or OnEraseBkgnd() in MFC). The default code for this is to clear the area of the screen, which is the main part of the flickering.
2. You need to use a MemoryDC to draw everything to (this usually includes erasing the background) then the last thing you do is copy the MemoryDC to the screen DC.
There is no need for me to show you any code as there is an endless supply on Google[^] and also right here on the Code Project[^]
|
|
|
|
|
Hi,
I have been working on my project about remotely sensed image processing, and image sequence looping. Each resulting image (in JPEG or PNG format) has approximately 8000 * 4000 pixels. Our users usually want to loop an image sequence (more than 50 images) on the basis of region of interest at a time. Thus, I have to extract the required viewing area from the each image according to user's visualization client size. For example, if user's current client view is 640 * 480, I'll have to find a size of 640 * 480 data block from each original image based on the current x (columns) and y (rows) coordinates, and remap to the client view. When user pans to another viewing area by mouse dragging, our program must accordingly re-load regional data out of each original image as soon as possible.
I know neither JPEG library nor PNG library has some built-in data block read routines, such as
long ReadRectangle (long x0, long y0, long x1, long y1, char* RectData);
long ReadInaRectangle (long x0, long y0, short width, short height, char* RectData);
The built-in JPEG decompressor lacks this kind of functionality. I know that JPEG2000 format has provisions for decompressing a specific area of the image. I'm not entirely sure about JEPG.
Someone suggest that I use CreateFileMapping, MapViewOfFile, and CreateDIBSection to commit the number of bytes of a file mapping to map to the view. Unlike the simple flat binary image formats such *.raw, *.img, and *.bmp, JPEG's Blob will contain not only the image data but also the complicated JPG header. So it's not easy to map a block of data view out of the JPEG file.
Someone recommend that I use image tiling or image pyramid technology to generate sub-images, just like mnay popular, image visualization (Google Earth, and etc.), and GIS applications (WebGIS, and etc.) do.
How can I solve this problem?
Thanks for your help.
Golden Lee
|
|
|
|
|
you can grab kinda-specific sub-rects out of a JPG. it's not a simple task, but if you realllly need it, it can be done. google for "jpegcrop" or "jpegtran". basically, a JPEG is encoded as a series of small rectangles, and (with clever programming) you can address the image data in terms of those rectangles.
i don't think there's a way to do it with PNG, though.
|
|
|
|
|
Hey,
I am working on this existing project and my job is to make some certain action occur when a particular tab in a dialog is selected. With this in mind, I am trying to use CTabCtrl::GetCurSel() but I am not having much success. I am aware that this function returns the zero-based index of the selected tab, which is the problem for me. At first, I used the nPageID value that was used in AddSSLPage() for the tab to see if the GetCurSel() return that particular tab but nothing happens.
At this point, I would like to know how can you find out the index of a tab? Any help will be greatly appreciated!!!
|
|
|
|
|
What do you mean with 'nothing happens'? Maybe you could show us your code, comparing nPageID with GetCurSel() is not a bad approach in itself.
'I would like to know how can you find out the index of a tab'. What do you use to identify a certain tab? Perhaps the CTabCtrl::GetItem[^] function can help you, it links a position to the label.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Thanks so much!!!
This is what I have
int selectedtab = m_tabcontrol.GetCurSel();
if(selectedtab == 2)
{
do some action
}
So are you saying if the second tab has nPageID is 2 and it is selected GetCurSel() should return 2?
|
|
|
|
|
nPageID is 0-based as well, so it should work nicely with GetCurSel().
The second tab, when you mean second when counting from left to right, would have an nPageID of 1 though; the leftmost tab has nPageID = 0 and then it goes up 1 for each tab to the right.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
Hi,
I have a jpg image on a IPicture* interface and I wish to save it to a file. Looking on MSDN it appears that I can use the IPicture::SaveAsFile() method but I don't relly understand what I need to do to get from a filename to being able to call SaveAsFile().
Could anyone please explain, or better still give me a few pointer (sorry for the pun ) to some code frags?
Thanks
Tony
|
|
|
|
|
I suppose you've to use SHCreateStreamOnFile [^], see, for instance, http://www.ureader.com/msg/1478976.aspx[^] (first reply).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks,
That works great!
|
|
|
|