Forum Discussion
Altera_Forum
Honored Contributor
14 years agomy code:
//================# include <io.h># include <system.h># include <stdio.h># include "gui.h"# include "altera_up_sd_card_avalon_interface.h" struct image images[MAX_NUM_IMAGES]; struct image *current_image; struct image *prev_image = NULL; int num_images = 0; int current_image_num = 0; short int file_handle1; char name1[] = "filexx.bmp"; // send image on Sdram to Sram_frame_buffer void send_image(int direction) { current_image = (direction == 2) ? current_image->next : current_image->prev; printf("current image: %d\n", current_image->image_num); int i = current_image->image_num; printf("sending image\n"); unsigned char byte_r, byte_g, byte_b; int pixel; int x, y; int x_start = 0; int x_end = IMG_X_SIZE; int x_inc = 1; for (x = x_start; x < x_end ; x += x_inc) { for(y = 0; y < IMG_Y_SIZE; y += 1) { // send request IOWR_16DIRECT(TV_TO_VGA_0_BASE, 16, 1); // set requested x and y positions IOWR_16DIRECT(TV_TO_VGA_0_BASE, 10, x); IOWR_16DIRECT(TV_TO_VGA_0_BASE, 12, y); // get pixel from memory byte_r = saved_images[0][y][x];byte_g = saved_images[1][y][x]; byte_b = saved_images[i][2][y][x]; if (num_images == 0) pixel = 0; else pixel = ((byte_r >> 3) << 11) | ((byte_g >> 2) << 5) |((byte_b >> 3) << 0); // send pixel IOWR_16DIRECT(TV_TO_VGA_0_BASE, 14, pixel); // reset request IOWR_16DIRECT(TV_TO_VGA_0_BASE, 16, 0); } } printf("sent\n"); }