CMFCRibbonGallery Being slow - c++

I am using the CMFCRibbonGallery control. I have 1 image it in comprised of 350 images total. Each image is 64hX128w. On the initial draw of the control it is slow. Every other time it is fast. I tried adding the 350 images individually at first but found that to be much slower cause it looks to be just making one large image like what I ended up doing. So I am wondering if there is anyway I can make this faster.

I ended up overloading OnDrawPaletteIcon which made me able to draw it much faster and manage the images myself.

Related

what is best used to optimize sfml project?

do 2d project simulator life. When there are many organisms, the project begins to hang, resulting in a marked decrease in the speed of organisms. What can you recommend? Perhaps the use of shaders to draw or there is something really useful?
It's gonna be difficult to help you without your code but I can still give you a few advices based on my own experience.
Since you're working with many "entities", there is probably some kind of interaction between these entities. If that is the case, a Quadtree (or a simple grid) could help lower the complexity of your algorithm.
But most of the time, SFML applications are slow due to inefficient rendering. There are a few ways to decrease rendering time :
Drawing everything at once (putting all your vertices in one array and draw that once instead of drawing a thousand rectangles one by one)
Drawing simpler objects (ex.: points instead of rectangles)
Drawing less often; You don't have to draw every time you update. Have a clock measuring the time since the last update and draw when the time (1/60th of a second for 60 FPS) is exceeded.
I don't know much about shaders but they seem a bit overkill for the job you wanna do.

Different Launch Screen Image or Background Image Sizes for iOS devices

I read some of those website links that explain about exporting different image sizes for iOS device. But I don't really understand of those explaining. (May be I am not good at in English language.)
I found these dimension for launch screen. Please let me clarify my understanding to you guys.
So, when I create an image, I must create a larger size(#3x) firstly and should export that image into smaller sizes (#2x, #1x). Am I right?
For example, I create 1242x2208px (3x) image and scale to 2x,3x and save.
My questions are that;
1) I draw images in Photoshop CS6.For any size of images, the Resolution is still 75px. isn't it?
So, for 1242x2208px(3x) size , the resolution is 75px and then I decrease the size. The image will small and does it get blurry appearance?
2) Does image elements (heart image in my example image)need to make to be large in smaller device(1x) to get the clear looks? Or
3) If we don't need to modify image elements or may be some texts of font size to be large or small, can we get the high resolution of image appearance in 1x? I'm afraid that if we scale to smaller(1x), it would be blur and not good in looks because we are still in 75 resolutions.
4) Does it need to make to fit the image elements to image size? I found this video https://www.youtube.com/watch?v=WOnczJSsMqk . In this video, he crops the white space and export into #1x, #2x and #3x. So, the size of #3x is not the image size from Apple official Guideline website. I don't know clearly this.
5) If we type the text (font size-90pt) in #3x image, then it will automatically changes to 60pt in #1x image. right?
But in this link https://www.smashingmagazine.com/2015/05/retina-design-in-photoshop/#font-size , he wrote that
a text box with the font set to 16 pixels. But #2x this is 32 pixels,
and #3x it’s 48 pixels!
Not ideal, is it, having to constantly multiply by two or three? I
don’t know about you, but I could do without the constant math. When I
design, I want to know that 16 pixels is 16 pixels!
So, the text should be 16 px in any size of image 1x,2x or 3x or not?
6) These image sizes are for launch screen, isn't it? But, if I create an image for background of Login screen, then is it the same concept and save as these sizes of image ?
7) Above image size dimension is correct or not? But, in this https://developer.apple.com/ios/human-interface-guidelines/graphics/launch-screen/ website, the sizes are a little bit different.
Now, I'm trying to create a design for login background image. So, I was finding the sizes before I draw. But, after reading many articles of image sizes in Retina device, I've confused and got many questions in my mind.
That's why I write down my questions like this and I would like to say sorry that my question is long and make you feel not easy to understand.
Sorry again for my poor English.
I hope anyone would help me to answer all my questions in steps.Thanks for reading till the end. :)
You are asking way to much here. First off, you do not work in pixels. You work in points. These are 2 different units of measurements. On a 1x scale 1 point = 1x1 pixel, on a 2x scale 1 point = 2x2 pixel, and on a 3x scale, 1 point = 3x3 pixels.
Now when it comes to how to scale, people claim that you start big and you got small for best quality. This is simply not true. It all depends on the actual image as to how it will scale. So your goal is to find what works best for the image. I would recommend starting off from big to small, but if it doesn't work out as nice as you like, go small to big, then try a different scaling method.
I personally do not rely 100% on automation, I like to tweak all 3 sizes manually until the images are perfect, which makes sprite-kit really tough to work with in this department because I have to design my graphics in a way that counter act the hardware scaling. Bottom line is at the end of the day, do what is best for your app within your budget constraints.
Now when it comes to font sizes, again you are working in points, not pixels. Whoever told you that you need to multiply has no understanding of how retina display works. So when you do 16pt font, the system will automatically pick 32pt and 48pt. (But if you read it it will still say 16pt)
Try not to over think this matter, it is really simple to understand. The entire point of retina display is to provide a sharper image while maintaining the same experience, and it does this by offering more granularity in the way pixels are displayed. Each individual pixel is very very tiny, which makes it hard to see with your eyes. Instead they are companions to other pixels, so that when your eyes put the 2 pixels together, you get a better looking image that could not be produced by using a single colored pixel. When you work on your apps, you want to keep this in mind. This is why it stinks for new people to get into development. Everybody should start with the iphone 2g, then adapt their app to iphone 4. They will get a clear understanding of what retina is built for.

Is it less computer intensive to load and unload an image every time a new image is needed or to have all of the images loaded at once? (SDL)

I've created a small animation for a game that uses a set of images as frames, and the current image to render changes over a certain amount of time to create the animation illusion. I've done this in two different ways, and I'm wondering which one is more efficient to use.
Method 1:
A single image is loaded and rendered. When a different image needs to be rendered, a function is called that unloads the current image, and loads and renders the new one.
Method 2:
All of the images needed for the animation are loaded once, and then rendered as needed.
In simpler terms: Method 1 unloads the current image and loads the new one every time a different image is needed, and Method 2 keeps all the images needed loaded at once.
So basically, the question is, it better to constantly load and unload images to keep as little loaded as possible, or to have many loaded at all times and not unload/load anything during the program? Does the computer have a harder time loading and unloading images or keeping many images loaded at once?
I ran looked at the task manager while running each method. CPU usage of Method 1 (loading and unloading) fluctuated between 29% and 30%, while that of Method 2 fluctuated between 28% and 29%.
It appears that keeping all the images loaded is better according to these statistics, but the reason I don't really trust them is because the program only loads seven images.
As the game gets bigger, there could be hundreds of images loaded at once (Method 2) or an image loaded and unloaded nearly every frame (Method 1). Which method is less intensive? Thank you for your time.
Firstly you dont define 'intensive'. Having a gaming machine using 100% is good - or at least not necessarily bad. It depends on what else is going on on your system.
Second, performance analysis is done by measuring, not by thinking. YOu have measured and found an answer. Believe the answer.
In general it is faster to store things in memory that to load off disk over and over again (as your measurement shows). However you will end up using a lot of memory (no free lunches here). You dont say how much memory you have or how big the images are. Assuming each image is 10mb, then 100 of them takes 1gb. ON a modern desktop thats not a lot, on an embedded system running on an arduiono its a disaster
Why not try with 100 images and see what happens
Measurement only confirms that doing less work results in faster execution, and doing something once is faster (in a long term) than repeating the same thing multiple times (if you'll restart your animation from first frame - you'll need to reload the same images again). More of a problem here is a latency - what if your image is considerably big and it takes noticeable time to load it, will you just stop rendering until it loads? What if hard disk is under heavy load (especially HDD, SSDs are not that vulnerable to random access) and suddenly image takes 100 times more time to load? (yes can still happen with CPU, but not that likely or extremely).
If you can predict what part of data will be used soon then you'll only need to load that part till specified deadline. It is generally referred as 'streaming' and especially helpful for very big but predictable data - like audio or video files (since you always know playback speed and direction). With animations it may be more difficult - sometimes you know what animation will be played (e.g. cutscenes or trigger), sometimes they're just too general and any of them could be played. In latter case you'll probably need to keep animation data ready to prevent unwanted pauses.
If data is too big you may try to do some compression (e.g. keeping data in memory in compressed form with some fast compression algorithm and decompressing when needed - much faster than reading from slow disk; special cases like for images there may be even better solution).

scanning plot through a large data file using python

I have a large (10-100GB) data file of 16-bit integer data, which represents a time series from a data acquisition device. I would like to write a piece of python code that scans through it, plotting a moving window of a few seconds of this data. Ideally, I would like this to be as continuous as possible.
The data is sampled at 4MHz, so to plot a few seconds of data involves plotting ~10 million data points on a graph. Unfortunately I cannot really downsample since the features I want to see are sparse in the file.
matplotlib is not really designed to do this. It is technically possible, and I have a semi-working matplotlib solution which allows me to plot any particular time window, but it's far too slow and cumbersome to do a continuous scan of incrementally changing data - redrawing the figure takes several seconds, which is far too long.
Can anyone suggest a python package or approach do doing this?
PyQtGraph is faster than Matplotlib but I don't know if it can plot 10 million points a second. It does also include multiple methods to down-sample your data so one of them might still be useful to you. Note that it requires Qt and PyQt.
Still, you have between 5e9 and 5e10 data samples. If you can simultaneously plot
10 million of them, this still means making between 500 and 5000 plots. Are you really going to inspect them all visually? You might consider to implement some kind of feature detection.
Something that has worked for me in a similar problem (time varying heat-maps) was to run a batch job of producing several thousands such plots over night, saving each as a separate image. At 10s a figure, you can produce 3600 in 10h. You can then simply scan through the images which could provide you with the insight you're looking for.

'creating' images effectively

I'll first tell you the problem and then I'll tell you my solution.
Problem: I have a blank white PNG image approximately 900x900 pixels. I want to copy circles 30x30 pixels in size, which are essentially circles with a different colour. There are 8 different circles, and placed on the image depending on data values which I've created elsewhere.
Solution: I've used ImageMagicK, it's suppose to be good for general purpose image editing etc. I created a blank image
Image.outimage("900x900","white");
I upload all other small 30x30 pixel images with 'read' function.
I upload the data and extract vales.
I place the small 'circle' images on the blank one using the composite command.
outimage.composite("some file.png",pixelx,pixely,InCompositeOp);
This all works fine and the images come up the way I want them too.
However its painfully SLOW. It takes 20 seconds to do one image, and I have 1000 of them. Surely there must be a better way to do this. I've seen other researchers simulate images way more complex and way faster. It's quite possible I took the wrong approach. Maybe I sould be 'drawing' circles instead of 'pasting' them or something. I'm quite baffled. Any input is appreciated.
I suspect that you just need some library that is capable of drawing circles on bitmap and saving that bitmap as png.
For example my Graphin library: http://code.google.com/p/graphin/
Or some such. With Graphin you can also draw one PNG on surface of another as in your case.
You did not give any information about the platform you are using (only "C++"), so if you are looking for a platform independent solution, the CImg library might be worth a try.
http://cimg.sourceforge.net/
By the way, did you try drawing the circles using the ImageMagick C++ API Magick++ instead of "composing" them? I cannot believe that it is that slow.